[英]How to handle push notification when app is in background but not suspended
[英]Handle local notification in background and suspended
我想在觸發本地通知時執行一些任務(假設應用程序在后台/掛起,但不在前台),而無需在通知上點擊用戶。 怎么可能? 我無法在application:didReceiveLocalNotification中獲得委托:如果應用程序處於后台/掛起狀態且觸發了本地通知,則無法使用。 請任何人可以提出一些解決方案。 提前致謝。
僅當應用程序在前台運行時才調用didReceiveLocalNotification
方法。 如果看到徽章並單擊應用程序以啟動它,則需要使用application:willFinishLaunchingWithOptions:
或application:didFinishLaunchingWithOptions:
application:willFinishLaunchingWithOptions:
處理本地通知,要以這兩種方法之一獲取本地通知,請使用UIApplicationLaunchOptionsLocalNotificationKey
作為選項字典的鍵。
如果您的應用處於暫停狀態,則您將無法知道該通知已被觸發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.