Can you wake up your phone from the WatchKit 1.0 app?

I am developing a client application that has geo objects to notify users when they approach one of the application providers.

When the location manager starts, it triggers a local notification with the firedate of the current date.

If the custom iPhone is locked and they have a paired Apple watch, it displays a custom notification on the watch. The user can either close the notification or click on the custom action button.

I would like a custom action button to wake up the phone and display the vendor page in the app. A type of automatic handover. The user expresses their desire to go to the supplier page by clicking the View Supplier page on the watch.

Is it possible? I am currently using a method +[WKInterfaceController openParentApplication:reply:]

to try and call the parent iOS app. However, if the phone is locked, nothing happens. IPhone screen remains dark, no sound, nothing.

If you unlock the phone, before pressing the action button on the watch, it calls the app and sends it a message displaying the provider's page.

As a second question, is it possible to configure the watch viewer app so that when the user clicks the notification button, the watch app sends a message to the iPhone app and closes the watch app? Right now, my client has no action on the OTHER watch than a custom notification that takes the user to the vendor page. The main screen of the watch app is just a placeholder at this point, and it looks silly when you press the custom action button and get that blank screen.

(As an aside, I know that in Watch Bundle 1.0, the watch app code actually runs on the iPhone, but it runs as a separate process, so it's helpful to talk about how the watch sends a message to the iPhone, although that's not exactly what's going on. )

+3


source to share


1 answer


The answer to this appears to be no, and no.

Apple views waking up the phone as something that the user has to do directly from the phone.

What I did was have the message openParentApplication:reply:error:

from the timezone to the phone look up the response dictionary from the iPhone, which includes a wasInBackground key / value pair containing bool YES or NO.

if wasInBackground == YES, it displays a modal message telling the user that they need to open the app on their phone to see the content.



If wasInBackground == NO, then the phone was awake and the app was in the foreground, so the app was able to display the content to the user.

Then, from the phone side, if the message on the watch comes in in the background, I check for the type of action the watch is asking for. If this is a request to display travel directions, I create a block that has code to display travel directions and set it in the "blockToRunOnReturnToForeground" property of the application delegate. Then, when the application delegate receives the applicationWillEnterForeground message, it checks for a non-nil "blockToRunOnReturnToForeground" and it is one, calls it and cancels it.

As a result, when the user finally brings the application back to the foreground, it then issues a ride request.

The user interface is not quite as seamless as we would like, but at least the user is not completely confused as to why nothing happens when they press one of the action buttons on the watch.

0


source







All Articles