PhoneGap iPhone应用程序崩溃时推送通知轻叩 [英] PhoneGap iPhone app crashing when push notification tapped

查看:150
本文介绍了PhoneGap iPhone应用程序崩溃时推送通知轻叩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode 4.2使用PhoneGap模板,城市飞艇图书馆。

Xcode 4.2, using PhoneGap template, Urban Airship library.

Xcode编译我的应用程序,并将其安装在我的iPhone上,我可以从Urban Airship Web界面。

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.

我已经从 http://urbanairship.com/docs/apns_test_client.html ,并使其在我的iPhone上正常工作:我可以收到通知城市飞艇,当我点击通知,应用程序打开,即使应用程序不是在后台。当然,这个例子不使用PhoneGap。

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.

推荐答案

这是phonegap中的一个小错误。

This is a small bug in phonegap.

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

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

这篇关于PhoneGap iPhone应用程序崩溃时推送通知轻叩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆