简体   繁体   English

对于Swift中的Apple Watch OS,如何在WCSession激活完成后运行功能?

[英]For Apple Watch OS in Swift, how can I have a function run after WCSession activation is complete?

I have a method in my main interface controller class that I wish to run when the WCSession between the phone and watch has finished activating. 我的主界面控制器类中有一个方法,当电话和手表之间的WCSession完成激活后,希望运行该方法。 I know there is a didFinishActivation function in the WCSession class. 我知道WCSession类中有一个didFinishActivation函数。 However, how do I communicate the result of this function to my main interface controller class to run the function in there, after WCSession has finished activating? 但是,在WCSession完成激活后,如何将该函数的结果传达给我的主接口控制器类以在其中运行该函数?

您必须使您的接口控制器类符合WCSessionDelegate协议,然后在session(_:activationDidCompleteWith:error:) WCSession后将自动调用session(_:activationDidCompleteWith:error:)函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WatchOS2 WCSession WCSession可以在WatchKitExtension中拥有多少个代理? - WatchOS2 WCSession How many delegates can the WCSession have in WatchKitExtension? 如何在 swift 完成 api 调用后运行函数 - How to run function after an api call has been complete in swift 如何在 Swift 中的函数中的 return 语句之后运行代码? - How can I run code after the return statement in a function in Swift? Swift-函数完成后如何调用函数? - Swift - How to call a function after a function is complete? 错误:“消息回复花了太长时间” - WCSession观看OS2 - Error: “Message reply took too long” - WCSession Watch OS2 如何将Iphone的远程通知传递给Watch OS? - How to pass the remote notifications I have for Iphone to Watch OS? 我可以在没有配备XCode的Apple Watch的情况下在我的设备上运行我的应用程序,即使它具有Apple Watch目标? - Can I run my app on my device without a paired Apple Watch from XCode, even if it has an Apple Watch target? 如何在Swift中的Apple Watch中解析服务? - How to parse a service in Apple Watch in Swift? 如何在后台运行 watch os 应用程序 - How do I run watch os app in the background 如何获得REAL Apple Watch打开父应用程序 - How can I get the REAL apple watch to open parent application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM