![](/img/trans.png)
[英]WatchOS WCSession won't activate / WCsession missing its delegate
[英]WCSession Delegate | Is it necessary to call reply handler synchronously?
在委托函數返回之前是否需要調用ReplyHandler? 在可以回復之前,我需要進行幾次Web Service API調用,以下實現是否正確?
func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
DispatchQueue.main.async {
//Following function makes couple of API calls inside
//UIBackgroundTask and replies when
//background task time expires
//or response from API is received.
self.handleMessage(message, replyHandler: replyHandler)
}
}
不,可以獲取該塊的副本並稍后再調用,盡管如果您等待太長時間並且您的應用程序在后台運行,則可能會暫停。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.