有沒有辦法攔截用戶點擊推送通知或用戶點擊豐富推送通知操作按鈕,而無需啓動應用程序?我已經實施了所有必要的設置,以註冊推送通知,接收推送通知並處理簡單和豐富的推送通知,並且用戶點擊豐富推送通知中的某個操作按鈕。但是,當用戶點擊一些動作按鈕,應用程序啓動了,我可以在裏面處理:iOS通知操作無需打開應用程序
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
let notification = JSONParser.parseRichPushNotification(notification: response.notification.request.content.userInfo)
if let responseIdentifier =
{
print(response.actionIdentifier)
}
//......
}
我想,而無需啓動應用程序執行,例如一些背景動作,或者打開網頁瀏覽器,如果有是推送通知數據中的鏈接。在iOS中可以嗎?
我也發現了類似的問題:
- Is there a way to open urls received in a push notification without opening the app in ios 10?
- Handle Push Notification when the App is off, or without opening the App at all - iOS
- Android notifications actions without opening the app
但我認爲,我沒有找到我的問題的答案。我還閱讀了有關無聲通知的內容,但我不確定是否可以將它們用於此目的,即在用戶單擊操作按鈕時不執行自動啓動應用程序時執行某些操作。
順便說一句,我usine OneSignal推送通知
是否有人知道如何執行呢?在此先感謝
您是否在創建'UNNotification Action'對象時使用'foreground'選項?你不應該。如果您不使用'foreground',則您的應用將被允許處理該操作而不會到達前臺 –
我不使用本地通知,而是使用遠程通知。我通過推送通知收到操作按鈕,所以我認爲我不需要這些。我應該這樣做嗎? –
如果用戶點擊通知,那麼您的應用程序將啓動。而已。如果您的應用是通過通知啓動的,那麼只要您的應用打開,您就可以打開一個網址,但您的應用將首先顯示。 – Paulw11