[英]How can you get the payload of a push notification if app is already running in the background when the user taps the notification?
[英]How to handle push notification payload without tapping it when the app is in not running or background state
我必須在本地存儲我的iOS應用程序中所有通知的標題和正文,並在通知屏幕中顯示它們。 我可以使用以下內容存儲所有被竊聽的通知-
當應用處於未運行狀態或點擊推送通知時被殺死時,將調用此方法-
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {...}
當應用在前台或后台運行並且點擊了推送通知時,就會調用此方法-
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {...}
我的問題是如何在不點擊通知的情況下存儲通知。 我希望存儲通知,即使通知被用戶拒絕/清除也是如此。
我知道當應用程序處於活動狀態並且在前台和推送通知到來時會調用此方法-
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {..}
當應用程序處於后台或未運行狀態時,如何在不點擊推送通知數據的情況下進行處理?
1-如果應用程序未運行,則無法僅通過(VOIP)喚醒應用程序
2-如果在后台,則將此密鑰添加到發送的負載中
“ content_available”:是
並從應用程序功能啟用RemoteNotifications
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.