繁体   English   中英

当应用程序未处于活动状态时,如何通过单击“查看”按钮来处理APNS消息?

[英]How to handle APNS Message by clicking “View” button when the app is not in active?

是在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

但是,当应用程序处于活动状态(未使用该应用程序)时, 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];
    }

它总是返回(空)。

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

用这个 :

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

您可以通过使用以下命令检查无效状态:

if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM