For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Cordova iOS applications with MobileFirst start-up flow

The MobileFirst framework is initialized in the iOS platform to display a WebView in the Cordova app with MobileFirst.


main.m

In the main.m file the MobileFirst plug-in replaces the default main application AppDelegate with MFPAppDelegate.

#import <UIKit/UIKit.h> int main(int argc, char *argv[]) { @autoreleasepool { int retVal = UIApplicationMain(argc, argv, nil, @"MFPAppDelegate"); return retVal; } }


MFPAppDelegate.m

The MFPAppDelegate.m file is found in the plugins folder. This replaces the default Cordova AppDelegate.m file and initializes the MobileFirst framework before the view controller loads the WebView .

The didFinishLaunchingWithOptions method initializes the framework:

[[WL sharedInstance] initializeWebFrameworkWithDelegate:self];

Once the initialization succeeds the wlInitWebFrameworkDidCompleteWithResult checks that the MobileFirst framework has been loaded, invokes wlInitDidCompleteSuccessfully and creates listeners for receiving data (see MobileFirst Cordova plug-in initialization for analytics. The wlInitDidCompleteSuccessfully creates a cordovaViewController that connects to the default index.html page.

Once the iOS Cordova app is built in Xcode without errors, we can proceed to add features to the native platform and WebView.

Parent topic: Developing Cordova apps for iOS