iOS example integration
This page shows a full example of how a completed integration would look like.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
#if DEBUG
XPush.setSandboxModeEnabled(true)
#endif
XPush.register(forRemoteNotificationTypes: [.alert, .sound, .badge])
XPush.applicationDidFinishLaunching(options: launchOptions)
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){
XPush.applicationDidRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
}
@implementation XPAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef DEBUG
[XPush setSandboxModeEnabled:YES];
#endif
[XPush registerForRemoteNotificationTypes:XPNotificationType_Alert | XPNotificationType_Sound | XPNotificationType_Badge];
[XPush applicationDidFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[XPush applicationDidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
@end
Updated over 3 years ago