Seguendo il percorso nel collegamento Michiel a sinistra (http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/), è possibile creare una classe il cui metodo init aggiunge un osservatore alla chiave UIApplicationDidFinishLaunchingNotification. Quando viene eseguito il metodo observer, le opzioni launchO sono contenute nell'userinfo della notifica. Stavo facendo questo con le notifiche locali in modo da questa è stata la realizzazione della mia classe:
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
Poi, quando mio contesto interno viene inizializzato ho verificare la classe NotificationChecker per vedere se l'applicazione è stata lanciata con una notifica.
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]);
}
La speranza che aiuta qualcuno!
qualsiasi fortuna Chon? – Sanniv
Suppongo che dovresti esaminare questo, una volta avrò il tempo: http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/ – Michiel
Devo aggiungere che è necessario un ANE (AIR Native Extension) per farlo funzionare. http://www.adobe.com/devnet/air/native-extensions-for-air.html – Michiel