2016-07-25 17 views
5

iOS9'da, bildirimlerden hoşlanıp bunları ayarlar sayfasına yönlendirerek kullanıcılarımıza bildirim izni verebilmemiz için kullanıcılarımızı yönlendiririz. Ancak, aşağıda gösterildiği gibi iOS 10 içerisindeki uygulama izinlerim ayarlarında bildirimleri etkinleştirmek için bir seçenek yoktur. Bu listeyi uygun izinlerle doldurmayı taahhüt ettiğim yeni bir süreç var mı?iOS 10 için bildirimleri nasıl etkinleştiririm?

enter image description here

Kod

//check the notifications status. First the global settings of the device, then our stored settings 
func checkGlobalNotifications() { 
    let grantedSettings = UIApplication.sharedApplication().currentUserNotificationSettings() 
    if grantedSettings!.types.rawValue & UIUserNotificationType.Alert.rawValue != 0 { 
     globalNotificationsEnabled = true 
     //if global notifications are on, then check our stored settings (user) 
     if CallIn.Settings.notificationsEnabled { notificationsOn() } else { notificationsOff() } 
    } 
    else { 
     globalNotificationsEnabled = false 
     //global notifications (iOS) not allowed by the user so disable them 
     notificationsOff() 
    } 
} 

cevap

8

iOS 10 tüm yerel üzere hemen kullanıldı ve push bildirimleri edilir UNUserNotificationCenter, tanıttı. Örneğin:

UNUserNotificationCenter.current().requestAuthorization(options: [.alert]) 
    { (granted, error) in 
     if granted == true{ 
      NSLog("Granted") 
      UIApplication.shared.registerForRemoteNotifications() 
     } 
     if let error = error { 
      NSLog("Error: \(error.description)") 
     } 
    } 

kullanarak ayarlarını kontrol edebilirsiniz getNotificationSettings()

WWDC Video: https://developer.apple.com/videos/play/wwdc2016/707/

`verilmiş sonra` UIApplication.shared.registerForRemoteNotifications() `yapılması gerektiğini eklersiniz
+0

== TRUE – KVISH

İlgili konular