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.

但是当应用程序处于In Active (The app not in use) 时 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)。

谁能帮我做到这一点?提前致谢。

4

1 回答 1

0

用这个 :

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

您可以使用以下方法检查非活动状态

if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive)
于 2012-08-10T15:08:54.607 回答