簡體   English   中英

通知服務擴展生命周期

[英]Notification Service Extension Lifecycle

我有一個關於通知服務擴展生命周期的問題,我已經搜索過,但我找不到適合我的問題的答案。 問題是當舊通知正在處理(尚未稱為 contentComplete)時出現新通知時會發生什么?

根據我的測試,它將結束舊進程並使用新通知開始新處理,用戶將錯過舊通知,所有數據尚未保存。 真的嗎?

我不是絕對肯定,但根據此處找到的 Signal 通知服務擴展代碼,您所說的是正確的。 他們解決它的方式是這樣的:

// The lifecycle of the NSE looks something like the following:
//  1)  App receives notification
//  2)  System creates an instance of the extension class
//      and calls this method in the background
//  3)  Extension processes messages / displays whatever
//      notifications it needs to
//  4)  Extension notifies its work is complete by calling
//      the contentHandler
//  5)  If the extension takes too long to perform its work
//      (more than 30s), it will be notified and immediately
//      terminated
//
// Note that the NSE does *not* always spawn a new process to
// handle a new notification and will also try and process notifications
// in parallel. `didReceive` could be called twice for the same process,
// but will always be called on different threads. To deal with this we
// ensure that we only do setup *once* per process and we dispatch to
// the main queue to make sure the calls to the message fetcher job
// run serially. 

確保你看到他們代碼的 rest

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM