【问题标题】:didFinishLaunchingWithOption not getting called when the action button of push notification is clicked单击推送通知的操作按钮时未调用 didFinishLaunchingWithOptions
【发布时间】:2012-04-04 04:35:39
【问题描述】:

我正在使用 Urban Airship 库实现推送通知。我能够从测试推送通知接收推送通知。现在,当我单击查看,即推送通知警报的操作按钮时,我的应用程序启动但也无法在 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)];

现在,当我使用测试推送收到任何通知并单击查看按钮时,我的应用程序将启动,但没有调用 didFinishLaunchingWithOption。我错过了什么吗?另外,当你查看通知时,我想显示我自己的用户界面。

如果我缺少任何东西,请指导我。还有一些示例,链接可能会有所帮助。 提前谢谢...

【问题讨论】:

    标签: iphone push-notification urbanairship.com


    【解决方案1】:

    也许该应用程序已经启动?您还需要实现:

    application:didReceiveRemoteNotification:
    

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

    【讨论】:

    • thanks men.. 这是在应用程序已经启动时被调用的.. didFinishLaunchingWithOptions 在操作按钮上被调用.. 我添加了警报对话框并运行应用程序并得到了回调以及何时...谢谢解决..
    猜你喜欢
    • 1970-01-01
    • 2018-08-20
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    • 2023-03-10
    相关资源
    最近更新 更多