Created
December 11, 2014 19:09
-
-
Save tayl0r/aef79937a11e10bf663e to your computer and use it in GitHub Desktop.
get launch options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)load | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; | |
// this one contains userInfo about our notification | |
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(FoxCubIosOnLoad:) name:UIApplicationDidFinishLaunchingNotification object:nil]; | |
// these two do not contain any useful userInfo about notifications | |
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(FoxCubIosOnLoad:) name:UIApplicationDidBecomeActiveNotification object:nil]; | |
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(FoxCubIosOnLoad:) name:UIApplicationWillEnterForegroundNotification object:nil]; | |
_launchStartTime = [[NSDate date] retain]; | |
// Initialize Bugsense so we can see unity startup crashes | |
[BugSenseController sharedControllerWithBugSenseAPIKey:@"xxxxx" userDictionary:nil sendImmediately:YES]; | |
NSLog(@"FoxCubIos: loaded"); | |
} | |
+ (void)FoxCubIosOnLoad:(NSNotification*) notification | |
{ | |
// This code will be called immediately after application:didFinishLaunchingWithOptions:. | |
// // we let the prime31 plugin handle the launch options now | |
// NSDictionary* launchOptions = [notification userInfo]; | |
// if (launchOptions == nil) { | |
// NSLog(@"FoxCubIos: launch options are null"); | |
// return; | |
// } | |
// NSURL* url = [launchOptions valueForKey:UIApplicationLaunchOptionsURLKey]; | |
// if (url == nil) { | |
// NSDictionary* payload = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; | |
// if (payload == nil) { | |
// id plist = [launchOptions valueForKey:UIApplicationLaunchOptionsAnnotationKey]; | |
// if (plist == nil) { | |
// UILocalNotification* localNotif = [launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; | |
// if (localNotif == nil) { | |
// NSLog(@"FoxCubIos: userInfo does not contain any launch options data."); | |
// } | |
// } | |
// } else { | |
// // handle payload | |
// | |
// } | |
// } else { | |
// // handle URL | |
// NSString* options = url.absoluteString; | |
// if (options != nil && options.length > 0) { | |
// [self SetLaunchOptions:options]; | |
// } else { | |
// NSLog(@"FoxCubIos: got url but it is broken"); | |
// _options = nil; | |
// } | |
// } | |
} | |
+ (void)SetLaunchOptions:(NSString*) options { | |
if (_options != nil) { | |
[_options release]; | |
} | |
_options = [options retain]; | |
NSLog(@"FoxCubIos: got launch options"); | |
NSLog(_options); | |
} | |
@end | |
// C functions to access your plugin from Unity script. | |
// Helper method to create C string copy | |
char* FcMakeStringCopy(const char* string) | |
{ | |
if (string == NULL) | |
return NULL; | |
char* res = (char*)malloc(strlen(string) + 1); | |
strcpy(res, string); | |
return res; | |
} | |
extern "C" const char* FcGetLaunchOptions() | |
{ | |
if (_options == nil) { | |
return NULL; | |
} | |
// By default mono string marshaler creates .Net string for returned UTF-8 C string | |
// and calls free for returned value, thus returned strings should be allocated on heap | |
char* rv = FcMakeStringCopy([_options UTF8String]); | |
_options = nil; | |
return rv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment