Understanding interaction between Apple Watch and iPhone device - ios

I am a bit confused as when I run the Apple Watch extension App schema on the simulator I see only that the Apple Watch app gets lunched. However I am not sure what will happen with real hardware once we get our hands on the Apple Watch.
I'd like to understand the following:
Do I need to start the corresponding iPhone App on the phone before
starting the App on the Apple Watch?
If the answer to 1 is no then, can I
start an iPhone App from the App on the Apple Watch? If the answer to 2
is yes then how can I start the iPhone App in a way that is not in
the background? (I found handleWatchKitExtensionRequest can trigger
background tasks but I haven't found any documentation yet for
that - I also found the Handoff Api which allows you to resume a task on the device but I don't like that it requires an iCloud account and I am not sure how to structure an App/watch interaction without forcing the user to adopt iCloud).
Given that the Apple Watch App extension resides on the iPhone App
bundle does this mean that when you start the Apple Watch App it needs a
connection and proximity with the iPhone device? I assume that there will
be a bluetooth connection and that it won't be possible to start
some apps if the user and its watch are away from the Iphone (what's
the range?)
Many Thanks

No.
No.
Unless you are on a Wifi network recognized by both your Watch and your iPhone, they'll need to be relatively close to each other. Guessing at range is useless – a number of factors can impact the useable distance of BTLE.

Related

Make iOS application run at startup iPhone or iPad

I would like to do my app open when iPhone is turned on. I saw that have some people saying can be using voip key in Info.plist but I tried and can't to do that. Do someone have any idea to help me? Thanks
In short, iphone does not have any access to permission to edit about "onboot" or "onstartup."
Thus, without jailbreaking this would not be possible.
Check the links I provided on your comment.
This would not happen, your app will be active in background through pushkit only when your app dismissed before device goes off.
VOIP - The app provides Voice-over-IP services. Apps with this key are automatically launched after system boot so that the app can reestablish VoIP services. Apps with this key are also allowed to play background audio.
Even with "voip" present in "UIBackgroundModes" in "plist", iOS App does not auto start after device reboot in iOS10
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1

Can we lock a phone with iOS programatically?

I need to set a timer to lock an iPhone from my app. While using the application, after 3 to 5 minutes the phone should become locked.
Short answer: You can't.
Long Answer: For the security of iOS users, Apple does not allow any application to work with important hardware matters, such as locking the iPhone or controlling the usage of other apps. If your app even attempts to do such a thing (using any method, like external APIs), your app will immediately be rejected by Apple. It is not even worth trying.
You cannot lock the screen programmatically without any private API. Even if you use a private API, your app may probably be rejected by App Store.
However you can indeed achieve by sending keyboard events from paired bluetooth hardware devices. But that means your code depends on a Bluetooth connection and I cannot think of any practice use of that. To do this with Bluetooth, click here.

CoreBluetooth advertising in background on iOS 10

First: I have an iPad Air 2, and an iPhone 7. For further reading we estimate that the app is active and open on iPad and in background mode on iPhone. The app is exactly the same, even with same Bluetooth Service UUIDs and same DataLocalNameKey.
I want to write an app that can advertise a bluetooth service in background and is able to discover this service (optimal in background too). As I already read I can't use apples beacon technology cause there it's only possible to get scanning/notified by beacons in near in background (I tested this, works fine) but not to advertise. So I started to use CoreBluetooth as described in the mentioned SO answer cause there it's possible to advertise in background.
My app calls didDiscoverPeripheral method in CBCentralManagerDelegate on the iPhone (app in background), so it detected the iPad. The isAdvertising property of CBPeripheralManager on iPhone is true. But didDiscoverPeripheral is not called on iPad. I'm a little bit confused. One option is my iPad is not able to detect the iPhone anymore for some reasons or my iPhone is lying and it's not advertising.
So i thought I'm just a little bit of dumb and googled for "CoreBluetooth debug apps". I found Vicinity and AltBeacon. And with both apps the behavior is the same! If you background (press home/sleep button) the advertising app, the browsing app is not able to discover it anymore. If you open the backgrounded the app it will instant discover it. Both apps mention that its possible with them to broadcast in background.
Am I doing something wrong; is this behavior expected? Did I misunderstood the framework? Can you confirm this behavior?
To confirm this, the fastest way is to install Vicinity on two devices (you have to add the NSBluetoothPeripheralUsageDescription key to Info.plist) set one device to broadcast and press the home button.
This isn't anything specific to iOS 10 -- it's always been this way on iOS. On iOS, apps simply cannot send out standard Bluetooth LE advertisements when they are in the background. They have to be in the foreground to do this.
That said, there is limited support in iOS for apps advertising GATT Services in the background. This uses a proprietary technique that only works with other iOS devices that are looking for those services. (Because it uses a non-standard proprietary scheme, the same technique won't work for beacon advertisements, for example.)
Here's how Apple describes it:
...you should be aware that advertising while your app is in the background operates differently than when your app is in the foreground. In particular, when your app is advertising while in the background:
The CBAdvertisementDataLocalNameKey advertisement key is ignored, and the local name of peripheral is not advertised.
All service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey advertisement key are placed in a special “overflow” area; they can be discovered only by an iOS device that is explicitly scanning for them.
If all apps that are advertising are in the background, the frequency at which your peripheral device sends advertising packets may decrease.
Read more here: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
it was a bug in ios 10.0.(1) and partially fixed in ios 10.1
src: https://forums.developer.apple.com/thread/51309

How can I make my Apple Watch app work without an iPhone?

When my iPhone is not available, my WatchKit app on the Apple Watch does not work (a red crossed-out iPhone symbol appears). How can I make my app work without the iPhone? How do I tell it to use data that is cached on my Apple Watch?
You don't, because this is not how Apple Watch apps work at the moment. Your watch app does not run on the watch, it runs on the iPhone but displays its UI on the watch. When the phone isn't nearby, there's no place to run the code.
Apple has said that stand-alone watch apps will be possible this summer. Probably they'll announce it at WWDC in June.

Restrict future Apple Watch apps to capable devices only

I'd like to restrict the sales of my next app to devices that are able to control an Apple Watch (iPhone 5 at least).
I can't find (in the doc or on Internet) which value for UIRequiredDeviceCapabilities I should put in the info.plist file.
There is currently API for knowing whether a device is paired with Apple Watch.
Even simply from an iOS app review perspective, if a user downloads an app onto their iPhone that app is expected to provide value regardless of any external products.
See Apple's App Review Guidelines for more detail
There is no such API.
As you are also no doubt aware, requiring iOS 9 will also not assist you as it runs on iPhone 4S. While it is speculation, it is possible that this will de facto change if iOS 10 is released in September/October 2016, as expected, as that may remove support for older iPhones that cannot be paired with an Apple Watch (for mostly reasons of performance, unrelated to Apple Watch capability).
However, if you are wanting to do this because you want the app to only be used with the watch, be aware that App Store review requires that apps with WatchKit extensions need to also provide useful functionality in their own right, and cannot be solely the code backend for a watch app. Therefore, you would be expected to provide functionality to users who do not (and even cannot) attach an Apple Watch to their phones.

Resources