iPhone 城市飞艇发射选项问题
我有一个非常简单的问题,搜索并没有引导我找到答案。在我的 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 中提取与从 userInfo 中获取的相同信息,或者从程序未运行时发送的消息中的 launchOptions 中提取相同的信息吗?提前致谢 :)
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);
[[UAPush 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alertMsg = [apsInfo objectForKey:@"alert"];
NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alertMsg = [apsInfo objectForKey:@"alert"];