单击推送通知的操作按钮时,不会调用didFinishLaunchingWithOptions

时间:2012-03-19 17:00:16

标签: iphone push-notification urbanairship.com

我正在使用Urban Airship库实施推送通知。我能够从Test Push Notifications接收推送通知。现在,当我点击推送通知提醒的查看即操作按钮时,我的应用程序启动但无法在didFinishLaunchingWithOption和applicationDidBecomeActive中获得回调。以下是我在didFinishLaunchingWithOption中所做的事情,

// Check if App running in Simulator.
        [self failIfSimulator];

        NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

        if (remoteNotification != nil) {
            NSString *message = [remoteNotification descriptionWithLocale:nil indent: 1];
            NSLog(@"Message in didFinishLaunchingWithOptions: %@",message);
        } 

        //Init Airship launch options
        NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
        [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];

        // Create Airship singleton that's used to talk to Urban Airship servers.
        // Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
        [UAirship takeOff:takeOffOptions];

        // Register for notifications
        [[UIApplication sharedApplication]
         registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                             UIRemoteNotificationTypeSound |
                                             UIRemoteNotificationTypeAlert)];

现在,当我收到使用Test Push的任何通知并点击View按钮时,我的应用程序启动但是没有调用didFinishLaunchingWithOption。我错过了什么?此外,我想在查看通知时显示我自己的ui。

请指导我如果我遗失任何东西。还有一些样本,链接可能会有所帮助。 提前谢谢......

1 个答案:

答案 0 :(得分:2)

也许该应用已经推出?您还需要实现:

application:didReceiveRemoteNotification:

在那里,即使应用程序已经启动,您也会收到通知。