iOS App Internal Control Transfer - ios

I am a novice to iOS app development. While using the StoryBoards for creating the iOS app, the control transfers from applicationDidFinishLaunchingWithOptions() methods to the viewDidLoad() method directly without any code been mentioned in the applicationDidFinishLauching() method.
What is the internal process that occurs in this scenario.
I have seen in the main.m file that there is a piece of code which calls the AppDelegate.class, but nothing such is present in the applicationDidFinishLaunching() method.

You have a default storyboard with initial controller (the arrow incoming to controller). this controller is initiated first after Application initialization is done. I mean, there is no explicit code for this, the Cocoa makes it for you.

Related

Xamarin iOS - where does application initialization code go?

I'm building a Xamarin iOS app which uses Ninject (a DI framework). I'm wondering where do I put the code that loads the modules and does the initialization of my application classes?
Would I put it in the application's delegate class?
In the Main.cs class?
In my first ViewController class (which is a menu view so it doesn't really make sens)?
What's the best practice? I can't seem to find it on google.
Due to the fact the UIApplication runloop is created/initialized during the UIApplication construction, I would avoid using the Main entry point as global app initiation point as the app's runloop is not available. Calling any iOS framework members during this phase can led to strange app behavior, crashes, file corruption, etc..
Also any initialization code that hangs (delays) the app at this point will cause the OS to kill your process and any external crash reporting will not happen. Apple's crash reports will be very generic SIGABRT reports.
The UIApplicationDelegate is also created during the UIApplication construction and the FinishedLaunching (application:didFinishLaunchingWithOptions:) delegate method is messaged after the UIApplication, its runloop and UIApplicationDelegate are constructed, but before the UIWindow and root VC are, thus making it the preferred delegate override.
In the FinishedLaunching method of AppDelegate.cs is one place for sure, but in several apps I have needed dependencies resolved prior because they are used in FinishedLaunching, so I have become accustomed to put this in the Main method of App.cs instead.
Here is a very simple example for an app that used Splat.Locator for rudimentary DI:
public class App
{
private static void Main(string[] args)
{
// Register platform-specific dependencies.
RegisterDependencies();
// Launch UI.
UIApplication.Main(args, null, "AppDelegate");
}
private static void RegisterDependencies()
{
// Akavache secure cache encryption provider.
var encryptionProvider = new KeystoreBackedEncryptionProvider(Akavache.BlobCache.TaskpoolScheduler, CacheManager.AppName, CacheManager.CacheName);
Locator.CurrentMutable.RegisterConstant(encryptionProvider, typeof(Akavache.IEncryptionProvider));
}
}
AppDelegate is usually the place you would put any app startup code

How does framework like KIF or EarlGrey access the running application?

Usually in iOS unit tests, we create new objects, call the method we wanna test, and then validate the results. This is a stand-alone procedure. The test cases always start running with the app instance but we do not access that instance directly.
However, with the framework like KIF or EarlGrey, we are able to write functional tests by accessing UI elements with accessibility labels in the running app instance. I am wondering how it is implemented. We don't have something like context or root view controller object when tests start, how does the framework find the presenting view controller from "nowhere"?
Because they are based on XCTest's Unit Test paradigm. In it, the tests and the app are both in the same bundle and therefore have access to the app internals.
Using [UIApplication sharedApplication], you can actually get the UIWindow for the app and find the entire View Hierarchy.

Opentok not calling the controller methods (sessiondidconnect) in ios

I am trying to implement an OpenTok application using codename one. I already started with android and had pretty much everything working. I use a native interface to import the OpenTok library.
Now I am trying to implement the ios side. I have a class acting like the view controller :
#interface be_lsit_opentok_iosTestHelper <OTSessionDelegate, OTPublisherDelegate> : NSObject
This class implements all the needed methods for the session connection : https://tokbox.com/developer/tutorials/ios/basic-video-chat/ (step 4).
My class implementing the native interface handles the initialization of the session with the api_key... and then calls the session's "connectWithToken".
Once this is done I can notice using the OpenTok Playground that the connection works but I do also notice that opentok does not send a message to call the method "sessionDidConnect" which is a problem.
I do not understand why the call is not done and what sould I do?
I also tryed to call the method myself using a thread call the method only when the connection to the session is made and that its status is "OTSessionConnectionStatusConnected" and this worked.
I'm guessing here since I didn't do this. You implemented the viewDidLoad in your own code instead of the Codename One view did load.
You can inject code into the Codename One viewDidLoad method using the build hint ios.viewDidLoad. So a build hint like:
ios.viewDidLoad=[self connectToAnOpenTokSession];
Should work but you would also need to add an import for the API into our code. Unfortunately I couldn't find a suitable build hint to define that so I added one ios.viewDidLoadInclude which I will add tomorrow to the build will allow you to define an import or include statement required by the statement above.

Push notifications in Delphi XE6 are displayed

I played with TPushEvents on Android for a while and noticed: when app is minimized push notification immediately goes right to the notification area. I suppose that this behaviour is defined in the native code (inside com.embarcadero.gcm.notifications.GCMNotification).
Can anyone confirm or refute my guess?
How this behaviour can be turned off? (I need to decide by myself whether notification should be displayed to a user.)
An alternative way is to inherit FMXNativeActivity class and overrid its public void receiveGCM(Bundle bundle) method but not deal with pause condition.
I myself can confirm this guess.
Decompile classes.dex, rewrite com.embarcadero.gcm.notifications.GCMNotification to suite your needs, compile and put it back inside classes.dex using the script from here.
I'm just not sure it's legal.

IOS - failed to start the app

I just tried to run my test app and I got this error:
2012-06-16 09:09:10.737 BusinessPlan[832:f803] Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard_iPhone' - perhaps the designated entry point is not set?
How do I set the designated entry point? And what is that?
Also, when I was going through their intro tutorials, the last time I ran the simulator was on the color-change step, and that worked for me.
In your story board file select the viewController you want to assign as first controller and check on is initial View Controller check the image
I've not done an immense amount with storyboards yet, mostly with the older nib/xib based flow.
However...
This looks like: When the app launches it creates an instance of UIApplication. This instance then needs to know what storyboard to go and connect to in order to create the user interface.
Looks like that link is missing in your app.
In the olden days you would either explicitly tell the app, in code, which nib to load or else you would have the link specified in interface builder.
I believe in the world of storyboards it is now more abstract and disconnecting the interface from the app by mistake is not easy to determine and fix.
I would recommend first going through the programming guide for storyboards on Apples developer site, or else start looking in the story board file for missing connections to it's delegate.
This isn't an answer per se, apologies, more of a guide to where to find one.

Resources