Skip to content

Instantly share code, notes, and snippets.

@keewon
Last active February 25, 2016 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keewon/6128736265ef86243234 to your computer and use it in GitHub Desktop.
Save keewon/6128736265ef86243234 to your computer and use it in GitHub Desktop.
Subclassing UnityAppController
//
// MyUnityAppController.h
//
#import "UnityAppController.h"
@interface MyUnityAppController : UnityAppController
@end
//
// 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