我有一个非常简单的问题,搜索并没有让我找到答案。在我的 application:didFinishLaunchingWithOptions 方法中,我执行以下操作来恢复程序未运行时收到的通知:
//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
[UAirship takeOff:takeOffOptions];
[UAPush shared].delegate = self;
[[UAPush shared] resetBadge];
// Register for notifications through UAPush for notification type tracking
[[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
当程序运行时(在前台或后台),我可以这样恢复我的飞艇警报:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"\nReceived remote notification:\n%@\n\n", userInfo);
[[UAPush shared] handleNotification:userInfo applicationState:application.applicationState];
[[UAPush shared] resetBadge]; // zero badge after push received
NSString *alertMessage = [[userInfo objectForKey:@"aps"] valueForKey:@"alert"];
}
我的问题是:当程序在前台或后台运行时,我可以执行什么命令序列来提取从 userInfo 中获得的相同信息,从程序未运行时发送的消息的 launchOptions 中获得?提前致谢 :)