#import "UIKit/UIKit.h" // Include our C++ class #include "pushnotifications.h" // This is hidden, so we declare it here to hook into it @interface QIOSApplicationDelegate @end //add a category to QIOSApplicationDelegate @interface QIOSApplicationDelegate (APNSApplicationDelegate) // No need to declare the methods here, since we’re overriding existing ones @end @implementation QIOSApplicationDelegate (APNSApplicationDelegate) - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Register to receive notifications from the system [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [application registerForRemoteNotifications]; NSLog(@"registered for remote notifications"); return YES; } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Did Register for Remote Notifications with Device Token (%@)", deviceToken); NSString *token = [self hexadecimalStringFromData:deviceToken]; PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(token)); } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { NSLog(@"Did Fail to Register for Remote Notifications"); NSLog(@"%@, %@", error, error.localizedDescription); } @end