我处在一个环境中(Adobe AIR),无法覆盖didFinishLaunchingWithOptions。是否有其他方法可以获取这些选项?它们存储在某个全局变量中吗?或者有人知道如何在AIR中获取这些选项吗?
我需要这些选项用于Apple Push Notification Service (APNS)。
我处在一个环境中(Adobe AIR),无法覆盖didFinishLaunchingWithOptions。是否有其他方法可以获取这些选项?它们存储在某个全局变量中吗?或者有人知道如何在AIR中获取这些选项吗?
我需要这些选项用于Apple Push Notification Service (APNS)。
按照Michiel留下的链接(http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/)中的路径,您可以创建一个类,该类的init方法向UIApplicationDidFinishLaunchingNotification键添加观察者。当执行观察者方法时,启动选项将包含在通知的userInfo中。我正在使用本地通知进行此操作,因此这是我的类的实现:
static BOOL _launchedWithNotification = NO;
static UILocalNotification *_localNotification = nil;
@implementation NotificationChecker
+ (void)load
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createNotificationChecker:)
name:@"UIApplicationDidFinishLaunchingNotification" object:nil];
}
+ (void)createNotificationChecker:(NSNotification *)notification
{
NSDictionary *launchOptions = [notification userInfo] ;
// This code will be called immediately after application:didFinishLaunchingWithOptions:.
UILocalNotification *localNotification = [launchOptions objectForKey: @"UIApplicationLaunchOptionsLocalNotificationKey"];
if (localNotification)
{
_launchedWithNotification = YES;
_localNotification = localNotification;
}
else
{
_launchedWithNotification = NO;
}
}
+(BOOL) applicationWasLaunchedWithNotification
{
return _launchedWithNotification;
}
+(UILocalNotification*) getLocalNotification
{
return _localNotification;
}
@end
BOOL appLaunchedWithNotification = [NotificationChecker applicationWasLaunchedWithNotification];
if(appLaunchedWithNotification)
{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
UILocalNotification *notification = [NotificationChecker getLocalNotification];
NSString *type = [notification.userInfo objectForKey:@"type"];
FREDispatchStatusEventAsync(context, (uint8_t*)[@"notificationSelected" UTF8String], (uint8_t*)[type UTF8String]);
}
[notification userInfo]
对我来说是一个空字典 =[ count == 0
- grisevg