2012-08-10 52 views
1

我是新來的iPhone應用程序中使用APNS。我已在所有情況下使用並接收了該消息。當user clicks the "View" button from the APNS alert i should do the actions in the app and navigate the user to 3rd tab如何在應用程序未處於活動狀態時單擊「查看」按鈕來處理APNS消息?

但是,當應用程序在在活動(該應用程序未使用)i can't trigger the actions in the app。我在「didFinishLaunch」中使用了下面的代碼,但未使用。

NSString *params=[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"aps"]; 
    NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey]; 
    NSLog(@"remoteNotif : %@", remoteNotif); 
    if ([params length] > 0) 
    { 
     UIAlertView *messageReceivedAlert = [[UIAlertView alloc] initWithTitle:@"My APP" message:@"New Message Recevied From APNS in IN-Active Stage" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
     [messageReceivedAlert show]; 
     [messageReceivedAlert release]; 
    } 

它總是返回(null)。

任何人都可以幫我做到這一點嗎?提前致謝。

回答

0

使用此:

- (void) application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo

而且你可以通過使用

if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) 
檢查不活動
相關問題