How to launch an associated watch app from an IOS application - ios

How do I launch an associated Watch App from an IOS App?
I do see questions where the user flow is in reverse, where the Watch App starts the IOS App in the background. However I want the reverse. I want to launch the Watch App, make it visible on the watch when the associated IOS App is running.
My current user experience is not good; I launch the IOS App from the Phone, then fiddle with the watch to find the associated Watch App.
The current IOS App plays music at times, and I have added the Now Playing View. I have also noticed that when I start the watch application "not programatically", some minutes later (after the watch goes to sleep and raised again to awake) the default music player Watch App is made the current watch application when playing music via the IOS App.
I would have preferred that the associated watch application is active on the watch, and that the Now Playing View controls the music.
The watch application has two views/pages where the user would swipe to move to the next page. The first page has some text and the second page has the Now Playing View
It would be far better, if the users starts the IOS App and auto launches the associated Watch App.
I am not sure what the design decisions are regarding this. Perhaps a Notification needs to be sent, and the user can then decide whether to launch the Watch App.
Please assist by giving brief API calls to make or adjusting properties in the plist.
Thanks.

You can do so by sending a workout configuration to your watch app via
startWatchAppWithWorkoutConfiguration
I'm not sure it would get past the App Review for non workout apps. You might have to call this method twice to reliably start the app, due to a timeout: forum discussion

Related

How to fully deactivate Apple App Clip - it still pops up

I added Apple App Clip but later removed it not yet needed. It was added "Advanced App Clip Experience", later deactivated, but when you bring the NFC tag to the phone, an alert still pops up with an empty content and message "This app clip is not currently available in your country or region".
Deactivated Advanced app clip in App Store Connect
Expired all builds in TestFlight, which contain App Clips
Everything in app association file, domains for app clips, etc - removed
So why NFC scanning still present App Clip, but not redirect me in app/safari as earlier?
I had the same problem. The fix was to ensure that the App Clip Experience was deactivated in App Store Connect.
I submitted a binary/build that contained an App Clip to Testflight so that I could access the Advance App Clip settings.
Deactivated the App Clip Experience (your step #1)
Waited a day to account for the caching system, and now, after testing, scanning my QR Code (in your case, it would be triggering the event with the NFC tag) produces the correct results.
It is important to note that even though you may have a live app that does not contain an App Clip, you must still deactivate it in Advance App Clip.

Trigger apple watch application launch from iPhone [duplicate]

I would like to give a hint to the user, that my iOS app supports the Apple Watch.
So I would like to link/open the Apple Watch companion app from within my iOS app, very much similar to opening the Settings App using ([[UIApplication sharedApplication] openURL: [NSURL URLWithString:UIApplicationOpenSettingsURLString]];)
This shall enable the user to directly navigate to the Watch companion app to setup my app for the watch.
I could not find any URL which would open the companion app in general or specific to a section of the companion app.
If direct linking is not supported, I am also interested in alternative approaches for this use case.
Thanks in advance!
EDIT:
I checked the WatchKitSettings Info.plist file in the simulator to see if it registers any URL schema, but it does not.
I guess it's not possible to programmatically launch the watch companion app from iOS. The opposite way would be possible: to launch the iOS app in the background upon receiving a message from the watch. See WWDC talk Introducing Watch Connectivity.
You could check WCSession.defaultSession().watchAppInstalled and ask the user to launch the app if it is true.
Previously, it was not possible to launch the WatchKit App from the iPhone app, but the iPhone app could be launched—only in the background—with the openParentApplication method.
As of WatchOS 2, however, it is now not possible for either app to cause the other to launch. Instead, there are new methods for queueing changes to be picked up when the other app is launched in the future.
One partial solution for your use case could be displaying a local notification which could be tapped to open the watch app. The primary flaw in such an approach is I do not believe there is a way to limit this notification to the Watch only, so it would also appear on the iPhone where if tapped it would bring the iPhone app to the foreground. Messy if implemented like this, and therefore not worth it I'd have thought, even if it could pass app store review.

iOS/Xcode: is there a difference between running the App on an iPhone while connected to Xcode compared to opening the installed App afterwards?

I have a Timer which plays AVAudio at a specific time while the screen is locked (app in foreground when locked and plist setting 'Application does not run in background' set to YES).
When I run my code while my iPhone is connected to Xcode it works as desired, playing audio while locked even when the iPhone has been locked for hours.
Now if I disconnect my iPhone and just open the app by tapping the icon the audio won't be played if it's set for more than a minute.
Is there a difference that causes this problem? If I would publish my App to the AppStore which behaviour would my users get?
That 'Application does not run in background' flag is a very old flag that means your app does not support multitasking and should be terminated when the user presses the home button. There's no good reason I can think of to set that flag on a newly developed application. Unless you understand exactly what it's for and are positive that setting it to yes is the correct thing to do, don't do that.
(That flag was added when iOS 4 was released, to allow apps that could not handle multi-tasking to request the old terminate-on-home-button behavior from iOS 3. Given that we're now 6 major iOS releases from iOS 4, it seems outdated.)
So remove that flag. It probably doesn't have any impact on your question, but remove it or set it to no in any case.
If you want to run a timer while the phone is locked and play sounds at designated times then you will probably need to set your app up as a background sound player, and ask for more background time when you get a message that you are going to the background.
That being said it's likely that Apple will reject your app. Running a timer from the background means that the processor on the phone has to run at full speed all the time, which will DRAMATICALLY reduce battery life.
Apple only allows a very small subset of apps to run in the background, and then only under specific circumstances (like a background sound playing app when the user is actively listening to music, or a navigation app that is actively tracking the user's location and notifying them when it's time to make a turn to follow directions.)
Should be no different. If you'd like to feel what do your users' feel then you can publish it to TestFlight which is the best app beta test environment. Find some testers or try it yourself.
The directions should be to verify the playing logic and the sound file relationship which link to the connection.

How to keep app running on apple watch instead of automatically going back to watch face?

I'm developing a WatchKit app that I want to stay in focus until the user actively selects another app or goes back to the watch using the digital crown. Just like with the built-in Workout app.
I don't want the app to be visible on screen forever, just that when I look at the watch after some minutes I want to have updated information for my app without having to go back to the app manually due to automatic switch to the watch face.
I don't think you can control this in your app, at least not in WatchOS 1. The only way I think this can be done is for the user to select "Resume To: Last Used App" in Settings > Activate on Wrist Raise.
Apps such as Nike+ currently advise users to change this setting before starting a run.
WatchOS 2 allows apps to register as fitness apps, that will contribute as a workout and will resume when the watch is activated / raised.

Apple Watch : will the App on iPhone run in the background

Am trying a simple Apple Watch App. the question I have is : will the iPhone App be able to run always in the background? In the App, I want to fetch some files from a server & store them in the iPhone (I want to do this everyday at a specific time), so that when the user opens the Apple Watch App, the file can be showed immediately (and no need to wait for it be downloaded then).
You can run tasks in the background of an iPhone application yes. I have no idea about how this interacts with the Apple Watch (your post suggests this will just sync automatically perhaps). Good point of reading:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Resources