我工作的一個應用程序iPhone和Apple關注之間共享數據,使用WCSession
方法sendMessage:replyHandler:errorHandler:
WCErrorCodeDeliveryFailed:有效載荷無法交付
實施該方法後,我得到這樣的錯誤:
WCSession _onqueue_notifyOfMessageError :withErrorHandler:errorHandler:YES和WCErrorCodeDeliveryFailed。
錯誤=無法傳送有效載荷。
import Foundation
import WatchKit
import WatchConnectivity
class ResultInterfaceController: WKInterfaceController, WCSessionDelegate {
override func awake(withContext context: Any?) {
super.awake(withContext: context)
let applicationData = ["name": "ViratKohli"]
self.sendToPhone(data: applicationData)
}
func sendToPhone(data: [String: Any]) {
if WCSession.isSupported() {
let session = WCSession.default
session().delegate = self
session().activate()
if WCSession.default().isReachable {
session().sendMessage(data, replyHandler: {(_ replyMessage: [String: Any]) -> Void in
print("ReplyHandler called = \(replyMessage)")
WKInterfaceDevice.current().play(WKHapticType.notification)
},
errorHandler: {(_ error: Error) -> Void in
print("Error = \(error.localizedDescription)")
})
}
}
}
....
任何幫助表示讚賞。
也許[這](http://stackoverflow.com/questions/33200630/wcsession-sendmessagereplyhandler-error-code-7014-wcerrorcodedeliveryfailed)不幫你嗎? –
@ReinhardMännernope。那沒有 – SahyadriChava