0

Xcode 4.2,使用PhoneGap 模板,Urban Airship 库。

Xcode 编译我的应用程序并将其安装在我的 iPhone 上,我可以从 Urban Airship Web 界面向它发送推送通知。

所以这是我的问题:如果我在应用程序在后台打开时点击通知,应用程序就会进入前台。但是,如果当我点击通知时应用程序尚未在后台,应用程序介绍屏幕会短暂出现,应用程序会立即崩溃。

至此,应用程序已经在后台,我可以打开它并进行操作了。

我已经从http://urbanairship.com/docs/apns_test_client.html下载并安装了库和示例应用程序,并让它在我的 iPhone 上正常工作:我可以接收来自 Urban Airship 的通知,当我点击时应用程序打开通知,即使应用程序尚未在后台运行。当然,此示例不使用 PhoneGap。

我希望也许其他人,经历过这个问题,或者至少可以识别症状,并且知道我可以做些什么来解决它。

4

1 回答 1

1

这是phonegap中的一个小错误。

在您的 AppDelegate.m 文件中查看 didFinishLaunchingWithOptions,如果您注释掉下面的行,该问题应该会消失。

- (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];
}
于 2012-02-04T18:36:03.450 回答