diff options
Diffstat (limited to 'platform/iphone/app_delegate.mm')
-rw-r--r-- | platform/iphone/app_delegate.mm | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 3c79137171..e5bd7a96b4 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -43,6 +43,11 @@ #import <AdSupport/AdSupport.h> #endif +#ifdef MODULE_PARSE_ENABLED +#import <Parse/Parse.h> +#import "FBSDKCoreKit/FBSDKCoreKit.h" +#endif + #define kFilteringFactor 0.1 #define kRenderingFrequency 60 #define kAccelerometerFrequency 100.0 // Hz @@ -51,6 +56,8 @@ #import "Appirater.h" #endif +Error _shell_open(String); + Error _shell_open(String p_uri) { NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()]; @@ -139,8 +146,9 @@ static int frame_count = 0; ++frame_count; // this might be necessary before here - for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { - NSObject* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:key]; + NSDictionary* dict = [[NSBundle mainBundle] infoDictionary]; + for (NSString* key in dict) { + NSObject* value = [dict objectForKey:key]; String ukey = String::utf8([key UTF8String]); // we need a NSObject to Variant conversor @@ -230,6 +238,8 @@ static int frame_count = 0; view_controller.view = glView; window.rootViewController = view_controller; + glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink",true)) ? YES : NO; + printf("cadisaplylink: %d", glView.useCADisplayLink); glView.animationInterval = 1.0 / kRenderingFrequency; [glView startAnimation]; @@ -341,6 +351,15 @@ static int frame_count = 0; // For 4.2+ support - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { +#ifdef MODULE_PARSE_ENABLED + NSLog(@"Handling application openURL"); + return [[FBSDKApplicationDelegate sharedInstance] application:application + openURL:url + sourceApplication:sourceApplication + annotation:annotation]; +#endif + + #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url]; #else @@ -348,6 +367,32 @@ static int frame_count = 0; #endif } +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { +#ifdef MODULE_PARSE_ENABLED + // Store the deviceToken in the current installation and save it to Parse. + PFInstallation *currentInstallation = [PFInstallation currentInstallation]; + //NSString* token = [[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding]; + NSLog(@"Device Token : %@ ", deviceToken); + [currentInstallation setDeviceTokenFromData:deviceToken]; + [currentInstallation saveInBackground]; +#endif +} + +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { +#ifdef MODULE_PARSE_ENABLED + [PFPush handlePush:userInfo]; + NSDictionary *aps = [userInfo objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + NSLog(@"Push Notification Payload (app active) %@", aps); + [defaults setObject:aps forKey:@"notificationInfo"]; + [defaults synchronize]; + if (application.applicationState == UIApplicationStateInactive) { + [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; + } +#endif +} + - (void)dealloc { [window release]; |