आईओएस 10 में, समाधान ऊपर मूल्यह्रास रहे
'cancelAllLocalNotifications()' आईओएस 10.0 में पदावनत किया गया था: उपयोग UserNotifications फ्रेमवर्क के - [UNUserNotificationCenter removeAllPendingNotificationRequests]
उपयोग रद्द करने के लिए नीचे दिए गए कोड अधिसूचना और रीसेट बैज गिनती
आईओएस 10 के लिए, स्विफ्ट 3.0
cancelAllLocalNotifications
,
import UserNotifications
प्राप्त होने पर सूचना केंद्र आईओएस 10.
@available(iOS, introduced: 4.0, deprecated: 10.0, message: "Use UserNotifications Framework's -[UNUserNotificationCenter removeAllPendingNotificationRequests]")
open func cancelAllLocalNotifications()
से
आप इस आयात बयान दर्ज करनी होगी पदावनत। और नीचे
application.applicationIconBadgeNumber = 0 // For Clear Badge Counts
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications() // To remove all delivered notifications
center.removeAllPendingNotificationRequests() // To remove all pending notifications which are not delivered yet but scheduled.
यदि आप एकल या एकाधिक विशिष्ट अधिसूचनाओं को हटाना चाहते हैं, तो आप इसे नीचे विधि से प्राप्त कर सकते हैं।
center.removeDeliveredNotifications(withIdentifiers: ["your notification identifier"])
उम्मीद है कि यह मदद करता है .. !!
स्रोत
2017-10-29 08:01:16
रद्द करेंअलोकोकल नोटिफिकेशन का उपयोग करें? यह दूरस्थ अधिसूचना है। टिप्पणियों के लिए धन्यवाद। – Tedha
ओपीएस क्षमा करें मुझे स्थानीय अधिसूचनाओं से भ्रमित हो गया है क्योंकि मैं आम तौर पर एक ही समय में दोनों का उपयोग करता हूं। – Icaro
या शायद यह भी मदद कर सकता है http://stackoverflow.com/questions/10971825/remove-remote-notifications-from-notification-center – Icaro