开发者

iPhone Urban Airship Launch Options Question

开发者 https://www.devze.com 2023-03-10 06:12 出处:网络
I have a pretty simple question that search has not lead me to the answer.In my application:didFinishLaunchingWithOptions method I perform the following to recover notifications that have come in whil

I have a pretty simple question that search has not lead me to the answer. In my application:didFinishLaunchingWithOptions method I perform the following to recover notifications that have come in while the program is not running:

 //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)];

While the program is running (in foreground or background) I can recover my airship alert as such:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
 NSLog(@"\nReceived remote notification:\n%@\n\n", userInfo);

 [[U开发者_如何学GoAPush shared] handleNotification:userInfo applicationState:application.applicationState];
 [[UAPush shared] resetBadge]; // zero badge after push received

 NSString *alertMessage = [[userInfo objectForKey:@"aps"] valueForKey:@"alert"];
}

My question is this: what command sequence can I execute to extract the same information obtained in alertMessage from userInfo while program is running in foreground or background, from launchOptions from messages sent while program was not running? Thanks in advance :)


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

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消