0

Xcode 4.2, using PhoneGap template, Urban Airship library.

Xcode compiles my application and installs it on my iPhone, and I can send push notifications to it from the Urban Airship Web interface.

So here’s my problem: If I tap on a notification while the app is open in the background, the app comes into the foreground. However, if the app is not already in the background when I tap a notification, the app intro screen briefly appears, and the app immediately crashes.

At this point, the app is now in the background, and I can open it and operate it.

I have downloaded and installed the Library and Sample App from http://urbanairship.com/docs/apns_test_client.html and have gotten it to work correctly on my iPhone: I can receive notifications from Urban Airship, and the app opens when I tap a notification, even though the app wasn’t already in the background. Of course, this sample doesn’t use PhoneGap.

I’m hoping maybe someone else, has experienced this problem, or can at least recognize the symptoms, and has an idea what I might do to fix it.

Rick
  • 557
  • 1
  • 7
  • 16

1 Answers1

1

This is a small bug in phonegap.

in your AppDelegate.m file look at didFinishLaunchingWithOptions, if you comment out the lines below that problem should go away.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //commented out because it makes the app crash at startup with local notification...
    /*NSArray *keyArray = [launchOptions allKeys];
    if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) 
    {
        NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]];
        self.invokeString = [url absoluteString];
        NSLog(@"Mosa_fr_en-busi launchOptions = %@",url);
    }*/

    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
Drew Dahlman
  • 4,952
  • 1
  • 22
  • 34
  • There are a few other options - http://stackoverflow.com/questions/6876559/phonegap-ios-localnotification-app-crashes-on-tapping-view/9047050#9047050 – Drew Dahlman Feb 05 '12 at 15:31
  • Thanks, Drew! I commented out the lines in didFinishLaunchingWithOptions, rebuilt the app, removed it from background on my iPhone, and sent a notification, and the app didn't crash this time when I tapped the notification. – Rick Feb 05 '12 at 21:12
  • After testing the app with the lines commented, I uncommented them and went through the process again, to verify that the previous behavior (app crashing) hadn't changed for some reason; and I finally recommented the lines. The crash behavior on my iPhone does indeed correspond to something in those lines of code. – Rick Feb 05 '12 at 21:19
  • awesome! yeah super strange bug, not too sure why those lines screw it up, but glad you were able to get it working :) – Drew Dahlman Feb 05 '12 at 21:21