简体   繁体   中英

WCSession: is it possible to cancel queued message?

Is there any way to cancel messages sent by the sendMessage(_:replyHandler:errorHandler:) method of WCSession ?

From the documentation :

Messages are queued serially and delivered in the order in which you sent them.

No. That type of transfer is not cancellable, as

  • the OS would have immediately sent any sendMessage data to a reachable counterpart

    Use the [sendMessage] method to transfer data to a reachable counterpart. These methods are intended for immediate communication between your iOS app and WatchKit extension.

    Data sent using the [sendMessage], and transferCurrentComplicationUserInfo: methods has a higher priority and is transmitted right away .

  • the OS provides no mechanism to specifically cancel a message

    The only WCSession objects that have a cancel method are WCSessionUserInfoTransfer , and WCSessionFileTransfer , since lower-priority transferUserInfo or transferFile data is not sent immediately, but at an optimum time determined by the OS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM