iPhone 城市飞艇发射选项问题

发布于 2024-11-13 06:20:43 字数 1374 浏览 4 评论 0原文

我有一个非常简单的问题,搜索并没有引导我找到答案。在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌辣 2024-11-20 06:20:43

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"];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文