iOS Watchkit: Is it possible to show static UI in Watch when app is not reachable? - ios

Can we show some static UI in the watch when iPhone is not reachable to AppleWatch?
Suppose I forgot my iPhone at car seat , and when I move from car, Is it possible to shows some static UI in AppleWatch that you forgot your iPhone?

From an Apple evangelist on https://devforums.apple.com/thread/254576?tstart=0
The end result is that if iPhone is unreachable, the app will not
function. There is not a way to currently cache information to keep it
alive or seemingly so.

Actually you don't have to do anything. I noticed on the real Watch, that Apple will present a default "iPhone unavailable" screen in case the iPhone is out of reach. Similarly, Apple will also present a default "flight mode" screen when the Watch is in flight mode :) . See attached screenshots.

In WatchOS 2, it is now possible to have a WatchKit App that runs on the Watch when the iPhone is not accessible.
Previous answer:
It is clear from Apple's public statements and the WatchKit API that third party developers do not need to manage the connectivity between the watch and the phone, and indeed cannot even if they want to.
Given Apple have publicly indicated that Watch app interactions are expected to be measured in seconds, not minutes, and that developers need to assume that their Watch app could be quit at any time (and the associated WatchKit extension) it seems highly likely that there will not be any option to present static content in the event of the phone being unreachable—as the Watch OS will immediately take over the process of interacting with the user.
It seems almost certain that this will change later in 2015, given developers have been told there will be an SDK to develop 'fully native' apps at that time.

Technically speaking you could start off the app storyboard scene with static content. if the phone is unreachable, then this scene will be displayed. But as soon as your app, whether programmatically or by user interaction attempts to use anything from the WatchKit Extension, a spinner will appear.

Related

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.

Sharing data among IOS App in MAC, iPhone, iPad and iWatch? Same App installed by individual user on multiple devices

Here things getting more passionate and difficult for me as a developer. I want to set up an app that would be capable to remind user for certain tasks at some specific time. The app would use LocalNotifications to remind the user.
Now, user may have this same app installed on his multiple devices, like iPhone, iPad, iWatch and MacOS. User would also change the time of those tasks and other parameters from any of the device he/she want to, I mean iPhone, iPad, iWatch or MacOS.
The operation on data amendments would then sync with all devices.
For instance, if user is having app installed on iPhone and he is set up with a tsk; i-e:
Task
{
taskId
taskName
taskTimeData
}
A task is initialised with name 'exampleTask' in iPhone and notification and every other option is also set in iPhone. After installing same app on iPad and setting the iWatch entitlement of the app.
Now the user must also receive similar functionality on both iPad and iWatch. Similarly, changing the name/timeDate of certain specific task must also update the task in other devices also.
Also must update the time for functionality execution in all the devices.
Please list all the available options in this regard, may become useful for other readers in future.
NOTE: I've gathered some of the related xCode entitlements but can't make myself understand.
1. App Groups
2. Keychain Sharing
3. Cloud Kit
Please explain options from xCode entitlements, I'm neither interested in any third party frameworks nor in web services and third party servers.

How to programmatically open Apple Watch companion app from iOS app

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.

WatchKit app "Unlock to activate"

My IOS app reads the heart rate from a bluetooth heart rate sensor, the heart rate is displayed on the Apple Watch. Everything works fine. But in most cases the user will lock the iPhone and put it in his pocket.
Here is the problem:
The IOS app is still working in the background and reading the heart rate but I can no longer display the data on the Apple Watch because the simulator displays "Unlock to activate".
Is it not possible to continue with the WatchKit app when the iPhone is locked and the IOS app is in the background?
I found the correct answer at the Apple Developer Forum:
Q: If you would like to debug willActivate/didDeactivate in a specific Interface Controller in your WatchKit app or Glance, once it is showing in the iOS Simulator, you can choose Hardware > Lock from the iOS Simulator menu bar to trigger didDeactivate. Repeat to unlock and trigger willActivate.
I found this in beta4, but some confusion. Is it just a test function in simulator? The app on real watch would not be locked after iphone locked, right?
A: Correct, it's just for testing.
Q: Is there a way to test the watch app in the simulator while the phone is locked? It seems like this would be an important test case as well, but right now the watch only shows "unlock to activate" while the phone is locked.
A: Not currently.
Link: (but you mast have a developer account) https://devforums.apple.com/message/1106203#1106203
Did you try something like this: Easy way to update app content via apple watch
Does calling openParentApplication not work when the iphone is locked?
When it comes to getting the iPhone to perform things in the background, openParentApplication works very well. Essentially, openParentApplication will run while your phone is locked.
This link: http://www.bignerdranch.com/blog/watchKit-extensions-communicating-with-your-parent-application/
has one of the best and easiest to understand tutorials I've found. Really helped me out, hope that helps.
You should be able to grab your data using openParentApplication
Good luck
Active background mode to ensure that the parent app has time to send its reply. For a code example on how to use the background mode, refer to Calling parent application from Watch app.

Lock iOS app in single app mode programmatically

Note : I don't want to submit this app to app store.
What i want to achieve :
I want simple app with one view having two button Lock and Unlock.
Lock - This button will lock device. Only this app's screen will show nothing else will be accessible even after restart same screen will show up. Home button, gestures will get disabled similar to single app mode.
Unlock - This will unlock device and switch to normal behaviour of device.
iOS :
I want this for iOS 4.3 and above.
I have checked following solutions, but these don't match my requirements
Configuration profile
Lock-down iPhone/iPod/iPad so it can only run one app
But it is manual (reboot device, open app which you want to run in single app mode). I want to do it programmatically the way i mentioned above through my app.
Guided access (iOS 6 and above)
How to lock down user to Single App mode in iOS 6, Programmatically?
I want it do for all os and programatically.
Is there any way to do this ? As i don't wan't to submit it to app store is there any private api, some hack for springboard to achieve this ?
Thanks in advance !!
As I know in iOS 7 there is a new feature which allow to do exactly what you want.
However, it's only applicable for iOS 7 (and I believe it's only applicable to a supervised devices).
1) You will need to install restriction configuration profile with autonomousSingleAppModePermittedAppIDs key (take a look here)
This is one time step and a user will need to manually accept this configuration profile.
There is another option to use MDM to install it silently, but it could be an overkill for you.
2) You should use API:
UIAccessibilityRequestGuidedAccessSession (to lock/unlock)
It is defined here
3) And most beautility part. All of it is officially document. So, you can even submit it to AppStore.
P.S. Why do you care about 4.3 or 5? They have tiny market share by now. Most likely even iOS 6 has below 20% market share already.
Update 1
Potentially, you can try to use API which sends clicks and keys (search for GSEvent in iPhone-privateapi tag). May be using these API's you can do triple home to toggle accessibility on and off.
If this work, I think you should be able to cover iOS 6. I am not sure whether both this API and triple home click were available prior that.
It looks like this private API is unaccessible anymore in iOS 7. So, probably you can ignore this idea.
Just wanted to write on this even though this is old as i needed to implement a similar solution and i got it working. The steps for me as follows and a note here is that this involves MDM and other specific steps.
My requirement was as follows. Each of the iPad at different locations has a set of apps installed.For ease of it lets assume each Dept. has their own apps. Participants open a app related to their dept. to take a test, the APP automatically Locks the iPad to single-app Mode and at the end of the test, it will unlock it self.
Supervise the iPad/iphone using the Apple Configurator.
Install the MDM related files ( Each MDM has its own set of instructions, usually involves downloading a profile).
Every MDM has a option of Single APP Mode or MultipleAppMode. Select the second option and add the app IDs to the list. (A single APP mode works pretty well with MDM's but i did not want the app to be locked to a single APP all the time).
I used the UIAccessibilityRequestGuidedAccessSession api to lock unlock the device from single app mode.
http://bobxcode.blogspot.com/2015/12/programmatically-implement-single-app.html
Thanks,
Bob
In MDM configuration, There is an option
autonomousSingleAppModePermittedAppIDs
Optional. Supervised only. If present, allows apps
identified by the bundle IDs listed in the array to
autonomously enter Single App Mode.
Availability: Available only in iOS 7.0 and later.
But this needs Supervised Device mode.

Resources