2016-09-28 4 views
18

आईओएस 10 में पदावनत मैं आईओएस में UIUserNotificationSettings को लागू करने से 10UIUserNotificationSettings

एप्पल प्रलेखन आगे उपयोग के लिए नीचे दिए गए ढांचा दिया है की वैकल्पिक तरीका के लिए देख रहा हूँ। लिंक here में UNNotification सेटिंग्स।

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { 
(granted, error) in 
//Parse errors and track state 
} 

यह:

किसी भी एक है जो मुझे नमूना कोड के साथ मदद कर सकते हैं बजाय अधिसूचना के

let notificationSettings = UIUserNotificationSettings(
     forTypes: [.Badge, .Sound, .Alert], categories: nil) 
    application.registerUserNotificationSettings(notificationSettings) 
+1

क्षमा करें मुझे अभी जवाब मिला है। http://stackoverflow.com/questions/37956482/registering-for-push-notifications-in-xcode-8-swift-3-0 – Prav

उत्तर

30

पंजीकरण UNNotificationSettings का उपयोग कर UIUserNotificationSettings के नीचे लागू करने के लिए वहाँ आप इस कोड को लागू करना चाहिए है resource में अतिरिक्त जानकारी है।

+0

इस कोड के नीचे 'application.registerForRemoteNotifications()' को न भूलें। –

+0

@ आईओएस। भेड़िया यह केवल तभी जरूरी है जब आप धक्का अधिसूचनाएं करने की योजना बना रहे हों जो स्थानीय सूचनाएं न हों। – zavtra

+0

उपयोगकर्ताNotifications.framework और @import UserNotifications के साथ भी लिंक करना न भूलें। – NickDK

संबंधित मुद्दे