Question

Our app is built for iOS with Cordova/Phonegap and we're trying to add some third-party libraries for application performance monitoring. Because our app also uses the Salesforce Hybrid SDK, we're currently unable to upgrade Cordova and so our version is stuck at 2.3.0. All of the services we've looked at require loading and initializing their SDKs in the didFinishLaunchingWithOptions method in AppDelegate.m. For example, the quick start instructions for one library looks like:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // other code for your app
    // ...
    [Crittercism enableWithAppID: @"52e9510d4002056e4300000b"];
}

I'm able to include the header files without any problems, but the method this should be in does not exist in the AppDelegate.m provided by the framework. When I try to add my own - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method to AppDelegate.h and AppDelegate.m, the Phonegap container never loads and the app just hangs with a black screen. Is there another way I can add this method to my AppDelegate, or with Cordova is there another place that third-party libraries such as crittercism can be loaded and initialized? Upgrading Cordova to the newest version is not an option. For reference, the complete AppDelegate.m implementation that I currently have is:

#import "AppDelegate.h"

@implementation AppDelegate

#pragma mark - App lifecycle

+ (NSString *) startPage
{
    NSString *superValue = [super startPage];
    return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"test"] ? @"test.html" : superValue;
};

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {
    return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);
}
// NOTE: be sure to call all super methods you override.

@end
Was it helpful?

Solution

Just realized that I was overriding didFinishLaunchingWithOptions without calling its original implementation as well. Fixed by adding [super application:application didFinishLaunchingWithOptions:launchOptions]; to my implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top