![](/img/trans.png)
[英]Will iOS awake my app when i receive silent push notification?(When app is not in running state)
[英]iOS Silent Push Notification does not receive when app in killed state
我想在收到靜默通知然后生成本地通知時根據某種條件顯示顯示通知。 還可以在xcode中啟用后台模式,並啟用遠程通知和后台獲取。 對於像這樣的靜默通知消息格式,
{
"message":{
"token":"iosdevicetoken",
"apns": {
"payload": {
"aps": {
"content-available": 1,
"category": "GENERAL",
"priority": "high",
"token": "randomkey",
"customkey": "abcs"
}
}
}
}
}
但是當應用程序處於終止狀態(從后台狀態滑動)時,不會調用下面的委托方法
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
}
這是故意的。 從application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
的文檔中:
此外,如果啟用了遠程通知后台模式,則系統將啟動您的應用程序(或將其從掛起狀態喚醒),並在遠程通知到達時將其置於后台狀態。 但是, 如果用戶強制退出應用程序 , 系統不會自動啟動您的應用程序 。 在這種情況下,用戶必須重新啟動您的應用程序或重新啟動設備,然后系統才會嘗試再次自動啟動您的應用程序。
(強調)
iOS認為用戶從任務切換器中刪除了該應用程序,這表明他們不希望該應用程序在后台運行。 因此,在用戶明確重新啟動該應用程序之前,iOS不會在后台重新啟動該應用程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.