2017-02-10 9 views
11

मैं एप्लिकेशन iPhone और एप्पल घड़ी के बीच कि शेयर डेटा, WCSession विधि sendMessage:replyHandler:errorHandler:WCErrorCodeDeliveryFailed: पेलोड वितरित नहीं किया जा सकता है

का उपयोग कर उस विधि को लागू करने के बाद मैं जैसे त्रुटि मिलती है पर काम कर रहा हूँ:

WCSession _onqueue_notifyOfMessageError : withErrorHandler: errorHandler: 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)") 
      }) 
     } 
    } 
} 
.... 

किसी भी मदद की सराहना की।

+0

शायद [यह] (http://stackoverflow.com/questions/33200630/wcsession-sendmessagereplyhandler-error-code-7014-wcerrorcodedeliveryfailed) आपकी मदद करता है? –

+0

@ रेनहार्ड मैनर नॉप। यह – SahyadriChava

उत्तर

5
  1. क्या आपके पास आईओएस साइड के WCSessionDelegate पर session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) है?
  2. क्या आप इस विधि के अंदर replyHandler() पर कॉल कर रहे हैं?

ध्यान दें कि session(_ session: WCSession, didReceiveMessage message: [String : Any]) केवल उत्तर के बिना भेजे गए संदेशों के लिए बुलाया जाएगा हैंडलर।

+0

नहीं था यह सही उत्तर है। यदि 'answerHandler' प्रदान किया गया है लेकिन अन्य ऐप' answerHandler' के साथ संस्करण को लागू नहीं करता है, तो अनुरोध विफल हो जाएगा। –

संबंधित मुद्दे