I would like to give a haptic feedback on the watch. That works fine as long as the watch app is active, but if the watch app goes in background the haptic feedback is not played. Is there a possibility to "wake up" the watch app from the parent IOS app to play the haptic feedback? (NOT A NOTIFICATION)
Since you prohibit Notifications, is not possible to do what you describe. Your watch app can act on messages from the iOS only when it starts up, resumes, or is currently loaded and running.
WatchConnectivity gives you 5 ways of sending data between the watch and phone.
sendMessage, sendMessageData: your scenario excludes these calls since both the watch and iPhone apps need to be active for this mechanism to work.
updateApplicationContext, transferUserData, and transferFile can be invoked from the iOS app at anytime, regardless of the state of your watch app. However, these messages are sent on a background thread and your watch app delegate will receive them the next time the watch app is loaded. By the design of the watch OS, none of these methods can trigger the watch app to load or become active.
Related
I've started to learn watchKit and watchOS.
After finding out how to handle notifications coming from a button set inside PushNotificationPayload.apns, I would like to set up my own notification that is going to fire at a given time, wake up the user with some kind of notification while the app is in the background, and possibly launch the app.
How can I do that?
In watchOS 2, this required scheduling the notification on the phone. It wasn't possible to wake up the watch app from the phone.
In watchOS 3, you can now use the new UserNotifications framework to schedule, deliver, and handle local notifications right on the watch.
You can display an actionable notification on the watch, which can open your watch app from the notification.
WWDC 2016 covered this material in two Introduction to Notifications and Quick Interaction Techniques for watchOS sessions.
I'm trying to create a feature where certain UILocalNotifications trigger a sound despite the fact that they are displayed in an Apple Watch, or if that's not possible, are not routed at all to the Apple Watch and just to an iPhone where they can play a sound. Having the watch produce a sound is not ideal compared to the iPhone since I need it to overlay any music the user is playing on headphones.
Obviously the user can disable notifications on the Apple Watch for the app, but there are cases where it is useful to receive notifications on the Apple Watch and that is an all-or-nothing solution.
The Apple documentation states:
When one of your app’s local or remote notifications arrives on the user’s iPhone, iOS decides whether to display that notification on the iPhone or on the Apple Watch.
Is there any information on how iOS decides where to display a notification? Is there any programmatic way to disable notification forwarding to Apple Watch?
You can selectively disable notification in apple watch: http://www.imore.com/how-turn-alerts-apps-apple-watch
See the answer in below link for app’s local or remote notifications guide:
https://stackoverflow.com/a/33581623/2401116
My scenario is control iphone music player on applewatch. Just like what the applewatch music glance would do. The project is gonna be iphone app, watch app, and watch extension. however, I want it to be able to work even thou my iphone app is not active. I know when iphone app is active, I could use wcsession and sendMessage to control the music on iphone. However, when the iphone app is not active. I don't know what I should do to get the work done.
One more thing, I don't understand how iphone app works when it is not active. Does it need to be active first do those job, or it is never really inactive so it could still do work?
Use this to wake up your iPhone App from your watch kit App in the background:
from https://developer.apple.com/library/prerelease/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/UpdatetheAppCode.html
Interactive messaging mode
sendMessage:replyHandler:errorHandler:
sendMessageData:replyHandler:errorHandler:
Use this mode to send data immediately to a counterpart app. If you do not want a response, you may specify nil for the replyHandler parameter.
The counterpart app must be reachable before calling this method. The iOS app is always considered reachable, and calling this method from your Watch app wakes up the iOS app in the background as needed. The Watch app is considered reachable only while it is installed and running.
Data is transmitted immediately and messages are queued and delivered in the order in which they were sent.
All you have to do is configure your App to respond to remote control events.
Remote Control events
Remote control events are any event received for the purpose of controlling media. eg iTunes pause/play/next/previous buttons available from the control center, or remote-control events from play/pause buttons on headphones.
Here is a tutorial on the subject.
Then your watch glance will be able to control the Apps audio.
With the current API as of Watch OS2 and iOS9, rewriting an glance similar to the now playing glance is not possible.
Is it possible to send instant notifications to Apple Watch from an iPhone app? The Apple Watch guide says "Apple Watch displays those notifications at appropriate times". So looks like there is no guarantee that the notification will be instant. I'm developing an iOS app that provides navigational notifications so those have to be instant.
Unfortunately WatchKit doesn't support it at this time. Not only can you not guarantee when the notification will appear, you can't even guarantee it will show up on the Watch. The OS decides which device is active and routes the notification there.
You can schedule/fire a local user notification to make it shown on the Watch, with limitations:
Users may turn off notifications of your app on Watch.
Notifications are only sent to Watch when the paired iPhone is locked, and the watch is on the wrist.
I am developing a WatchKit extension for one of my Apps where I really want to have the iPhone App running in the foreground, since it is doing the heavy lifting and is designed to use location services only when active. I know openParentApplication:reply only opens the App in the background (unless it is already active). What I am currently trying out is using a custom URL scheme for my App, and having the App initially open itself from within the handleWatchKitExtension code in the App Delegate. This works perfectly in the Simulator. Unfortunately I did not have this approach ready when I tested my App on real Apple Watches. Does anyone see a problem with this approach to bring the iPhone App to the foreground from the Apple Watch?
On iOS, apps can't bring themselves to the foreground. The best thing you can do is to post a local notification (UILocalNotification, see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html) and invite the user to bring your app to the foreground.
But for your use case, why not just have your phone app use location services in the background?
This is not possible. The Apple Watch Programming Guide states that the app on the iPhone will run in the background if it was not active before.