iPhone Urban Airship发布选项问题

ban*_*edo 2 iphone notifications push urbanairship.com

我有一个非常简单的问题,搜索没有引导我得到答案.在我的应用程序中: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)];
Run Code Online (Sandbox Code Playgroud)

当程序运行时(在前台或后台)我可以恢复我的飞艇警报:

- (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"];
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:当程序在前台或后台运行时,从程序未运行时发送的消息中的launchOptions,我可以执行什么命令序列来从userInfo中提取在alertMessage中获取的相同信息?提前致谢 :)

小智 7

NSDictionary*userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];

NSDictionary*apsInfo = [userInfo objectForKey:@"aps"];

NSString*alertMsg = [apsInfo objectForKey:@"alert"];