Last active
February 25, 2016 01:54
-
-
Save keewon/6128736265ef86243234 to your computer and use it in GitHub Desktop.
Subclassing UnityAppController
This file contains 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
// | |
// MyUnityAppController.h | |
// | |
#import "UnityAppController.h" | |
@interface MyUnityAppController : UnityAppController | |
@end |
This file contains 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
// | |
// MyUnityAppController.m | |
// | |
#import "MyUnityAppController.h" | |
#import "Tapjoy/Tapjoy.h" | |
IMPL_APP_CONTROLLER_SUBCLASS(MyUnityAppController) | |
@implementation MyUnityAppController | |
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions | |
{ | |
NSLog(@"MyUnityAppController didFinishLaunchingWithOptions"); | |
BOOL result = [super application:application didFinishLaunchingWithOptions:launchOptions]; | |
// Registering for remote notifications | |
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) | |
{ | |
// iOS 8 Notifications | |
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; | |
[application registerForRemoteNotifications]; | |
} | |
else | |
{ | |
// iOS < 8 Notifications | |
[application registerForRemoteNotificationTypes: | |
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; | |
} | |
// Tapjoy | |
[Tapjoy setApplicationLaunchingOptions:launchOptions]; | |
return result; | |
} | |
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken | |
{ | |
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
[Tapjoy setDeviceToken:deviceToken]; | |
} | |
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)err | |
{ | |
[super application:application didFailToRegisterForRemoteNotificationsWithError:err]; | |
} | |
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo | |
{ | |
[super application:application didReceiveRemoteNotification:userInfo]; | |
[Tapjoy setReceiveRemoteNotification:userInfo]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment