IOS远程推送通知不工作IOS9,它是完全工作的IOS10

时间:2017-01-27 11:04:04

标签: ios swift2 apple-push-notifications

IOS远程推送通知(testflight?)无法正常运行IOS9 IOS10。我该怎么办?

注意:我也正在通过apn测试器测试IOS9和IOS10它运行正常。我在swift 2中的项目。

完整代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    //ask for user to permited push notification
    registerForPushNotifications(application)

    //crate notification with sound alert, Badge , and sound
    let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]

    //add nofification type in system notification
    let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerUserNotificationSettings(pushNotificationSettings)

    //register for remot notificaiton not local

    return true
}    

//MARK:- Push Notification configaratin
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    if notificationSettings.types != .None{
        application.registerForRemoteNotifications()
    }
}
func registerForPushNotifications(application: UIApplication)
{
    let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

     //send Device Id

}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
{

    print("Failed to register:", error)
  }


func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    self.showingAlert("notification arived 3: \(userInfo)")       
}

推送通知:

Push notification

背景模式:

Background Mode

0 个答案:

没有答案