2016-12-26 5 views
-3

Initial importieren wir den UserNotifications Rahmen und wir initialisieren die delegierte Methode in AppDelegate.swift KlassePush-Benachrichtigung funktioniert nicht in schnellen 3,0

if #available(iOS 10.0, *){ 

     UNUserNotificationCenter.current().delegate = self 
     let center = UNUserNotificationCenter.current() 
     center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in 
      if (granted) 
      { 
       UIApplication.shared.registerForRemoteNotifications() 
      } 
      else{ 
       //Do stuff if unsuccessful... 
      } 
      // Enable or disable features based on authorization. 
     } 

    } 
+0

Haben Sie überprüfen, ob http://stackoverflow.com/questions/41035878/how- can-i-store-push-notification-alarmmeldung-in-userdefault/41037919 # 41037919 – Amanpreet

Antwort

-1

Bitte überprüfen Sie die "Push Notification" Schalter unter Target > Capabilities:

es ON

Drehen
-1

Ändern Sie Ihren Code wie dieser

let center = UNUserNotificationCenter.current() 
    center.delegate = self 
    center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in 
     if (granted) 
     { 
      UIApplication.shared.registerForRemoteNotifications() 
     } 
     else{ 
      //Do stuff if unsuccessful... 
     } 
     // Enable or disable features based on authorization. 
    } 

Und auch sicher sein, dass Ihre Server-Seite Skript gut funktioniert ...