Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following the path in the link Michiel left ( <a href="http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/">http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/</a> ), you can create a class who's init method adds an observer to the UIApplicationDidFinishLaunchingNotification key. When the observer method is executed, the launchOptions will be contained in the notification's userInfo. I was doing this with local notifications so this was the implementation of my class: </p> <pre><code>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 </code></pre> <p>Then when my extension context is initialized I check the NotificationChecker class to see if the application was launched with a notification.</p> <pre><code>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]); } </code></pre> <p>Hope that helps someone!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload