2012-03-19 27 views
1

我正在使用Urban Airship图书馆实施推送通知。我能够接收来自测试推送通知的推送通知。现在,当我点击推送通知提醒的查看即操作按钮时,我的应用程序将启动,但无法在didFinishLaunchingWithOption和applicationDidBecomeActive中获取回调。以下是我在我的didFinishLaunchingWithOption到目前为止做,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是没有得到调用。 AM我错过了任何东西?另外,我想在u查看通知时显示自己的ui。

请指导我如果我缺少任何东西。还有一些样本,链接可能会有所帮助。 在此先感谢...

回答

2

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

application:didReceiveRemoteNotification: 

在那里你会得到即使该应用程序已经启动的通知。

+0

感谢的人....当应用程序已经启动,这是被调用..也didFinishLaunchingWithOptions被调用的行动按钮。我加入警报对话框和运行应用程序,并得到它得到回调时...谢谢解决.. – Panache 2012-03-20 10:18:05