Offically supported Swift Demo for JPush iOS SDK.
pod 'JPush'
pod 'JCore'
运行pod install
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0) {
// 可以自定义 categories
JPUSHService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Alert.rawValue , categories: nil)
} else {
JPUSHService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Alert.rawValue , categories: nil)
}
JPUSHService.setupWithOption(launchOptions, appKey: appKey, channel: channel, apsForProduction: isProduction)
return true
}
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print("get the deviceToken \(deviceToken)")
NSNotificationCenter.defaultCenter().postNotificationName("DidRegisterRemoteNotification", object: deviceToken)
JPUSHService.registerDeviceToken(deviceToken)
}
到此 已经完成集成 JPush sdk 的基本功能,若需要更多功能请参考Demo工程