PhoneGap iPhone app crashing when push notification tapped

旧巷老猫 提交于 2019-12-13 04:14:24

问题


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.


回答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];
}


来源:https://stackoverflow.com/questions/9138075/phonegap-iphone-app-crashing-when-push-notification-tapped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!