2015-05-21 5 views
10

आईफोन स्क्रीन के शीर्ष से नीचे स्वाइप करते समय अधिसूचना बैनर से रिमोट अधिसूचना को साफ़ करने का कोई तरीका है। मैं शून्य करने के लिए बिल्ला नंबर की स्थापना की कोशिश की:अपने ऐप में रिमोट अधिसूचना कैसे साफ़ करें?

application.applicationIconBadgeNumber = 0 
प्रतिनिधि didFinishLaunchingWithOptions में

, और didReceiveRemoteNotification, लेकिन यह सूचनाएं स्पष्ट नहीं किया। धन्यवाद।

उत्तर

10

आपको IconBadgeNumber 0 पर सेट करने और वर्तमान सूचनाओं को रद्द करने की आवश्यकता है। मैं तेजी से में कभी नहीं किया था, लेकिन मैं कोड लगता है कि यह हो सकता है के लिए के रूप में bellow:

application.applicationIconBadgeNumber = 1 
application.applicationIconBadgeNumber = 0 
application.cancelAllLocalNotifications() 
+0

रद्द करेंअलोकोकल नोटिफिकेशन का उपयोग करें? यह दूरस्थ अधिसूचना है। टिप्पणियों के लिए धन्यवाद। – Tedha

+0

ओपीएस क्षमा करें मुझे स्थानीय अधिसूचनाओं से भ्रमित हो गया है क्योंकि मैं आम तौर पर एक ही समय में दोनों का उपयोग करता हूं। – Icaro

+0

या शायद यह भी मदद कर सकता है http://stackoverflow.com/questions/10971825/remove-remote-notifications-from-notification-center – Icaro

0

मैं तो बढ़ाने के लिए आदेश में बिल्ला गिनती घटती यह काम करने के लिए है

अपने AppDelegate.swift फ़ाइल के तहत didFinishLaunchingWithOptions ऐड में:

application.applicationIconBadgeNumber = 0 

आपके ऐप के लॉन्च पर यह आईओएस बैज (ऐप आइकन के ऊपरी दाएं कोने में लाल सर्कल) को हटा देगा।

1

स्विफ्ट 3:

application.applicationIconBadgeNumber = 0 
application.cancelAllLocalNotifications() 
7

आईओएस 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"]) 

उम्मीद है कि यह मदद करता है .. !!

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