iPhone Urban Airship 发射选项问题

标签 iphone notifications push urbanairship.com

我有一个非常简单的问题,但搜索没有让我找到答案。在我的 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 中提取从 AlertMessage 中获得的相同信息,从程序未运行时发送的消息中的 launchOptions 中提取相同的信息?预先感谢:)

最佳答案

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

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

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

关于iPhone Urban Airship 发射选项问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6221183/

相关文章:

git push 删除服务器上不在本地的文件

iphone - 如何在 iPhone 中实现 NSGraphicsContext

iphone - 来自 iphone 应用程序的定位服务

android - UrbanAirship 与 GCM 通知

android - 接收不同标准的多个推送通知并根据该标准更新通知

android - 实现 Android 通知应用程序的最省电方式

c++ - 在网络浏览器上流式传输 C++ 文件

ios - 如何将 iPhone SE 的设备方向仅保留为纵向?

iphone - 当发布的App对User Interaction无响应时,有什么好的方法可以获取有用的信息?

javascript - 在 AJAX 调用中发送 DIV 元素的 ID