Xcode 4.2,使用PhoneGap模板,Urban Airship library。
Xcode编译我的应用程序并将其安装在我的iPhone上,我可以通过Urban Airship Web界面向其发送推送通知。
所以这是我的问题:如果我在应用程序在后台打开时点击通知,应用程序就会进入前台。但是,如果我点按通知时应用程序尚未在后台,则会暂时显示应用程序简介屏幕,并且应用程序会立即崩溃。
此时,应用程序现在处于后台,我可以打开它并进行操作。
我已经从http://urbanairship.com/docs/apns_test_client.html下载并安装了图书馆和示例应用程序并且已经让它在我的iPhone上正常工作:我可以接收来自Urban Airship的通知,当我点击通知时应用程序会打开,即使该应用尚未在后台。当然,此示例不使用PhoneGap。
我希望也许是其他人,遇到过这个问题,或者至少可以识别症状,并且知道我可以做些什么来解决它。
答案 0 :(得分: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];
}