如何在 iOS 中檢視狀態列中啟用的通知?


要獲取狀態列托盤中啟用的通知列表,我們將使用 getdeliverednotifications,你可以在此處閱讀更多相關資訊。

https://developer.apple.com/documentation/usernotifications/unusernotificationcenter

https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649520-getdeliverednotifications

儘管大家都知道我們無法獲取所有應用程式的通知,因為這會違反隱私,但我們可以獲取我們應用程式的通知

Apple 提供 getDeliveredNotifications(completionHandler:)

它將返回仍然顯示在通知中心中的應用程式通知列表。

你可以根據自己的需求編寫以下程式碼。

UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
   print(notifications)
}

更新於: 30-07-2019

186 次瀏覽

開啟您的 職業

完成課程,獲得認證

開始
廣告
© . All rights reserved.