UIApplication.sharedApplication (). BeginIgnoringInteractionEvents () on Apple Watch

I cannot use

UIApplication.sharedApplication().beginIgnoringInteractionEvents()

      

in WatchKit Extension, I have an error:

'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.

      

Is there any alternative?

+3


source to share


1 answer


Short answer: No. Not.

Long answer:

Please keep in mind that the extension does not work on the watch, but on your phone. So if you call UIApplication.sharedApplication()

, this will bring you back the extension app on your phone, anyway! Everything you do inside your extension is stuff that manipulates your phone's extension. The only exception is WatchKit methods. And even these are basically calls that are translated into instructions that are sent over Bluetooth to tell you what to do. Under no circumstances can you write code that runs on the clock!



You have no control over what happens to the watch with the instructions you send to it. You are basically acting as a server talking to the client and you have no control over the client. You should send as few instructions as possible and once you send them your task is done and the rest is up to hours.

That being said, you should carefully plan your interface in such a way that you do not need calls that control the delivery of events. You should focus on simple "user interaction" x i do y.

Another thing to keep in mind is that your extension cannot communicate with your main iOS app. You can create a shared app group between your iOS app and the watch extension to exchange data between the two, however, you cannot communicate directly with your app. If you want to use parts of your application logic, extract the module in question into a framework (this has become very easy with Xcode 6) and use the framework in both your application and your extension.

+3


source







All Articles