WatchKit event for "devices not paired"? - ios

I want to be sure that when the Watch is not paired with an iPhone the user is warned with the right info. I saw that when I turn off bluetooth some other applications show a full screen red device icon with the name of the app in white, indicating that the device is not paired and that the app needs the pair to work. When I do the same using my App nothing happens, I'm still getting only a little icon next to the time on the to right (or left depending on wrist...) corner, not the full screen icon.
I wonder if is there a specific way to show that state to users or if it should be an automatic function handled by the system that, for some reasons, is not working for me.

Don't know about the automatic function but using WatchConnectivity framework you can get to know if the paired iPhone is reachable or not . If not you can show an interface controller with proper message to warn user. WCSession has a boolean property reachable whose description is as under.
Discussion
In your WatchKit extension, the value of this property is
YES when a matching session is active on the user’s iPhone and the
device is within range so that communication may occur. On iOS, the
value is YES when the paired Apple Watch is in range and the
associated Watch app is running in the foreground. In all other cases,
the value is NO.
For more detail check WatchConnectivity Framwork

Related

"CBCentralManager(delegate: self, queue: nil)" does not show Bluetooth popup message when Bluetooth is turned off from Control Center

I am trying to navigate the user to Bluetooth settings on a button click. CBCentralManager(delegate: self, queue: nil) works fine when Bluetooth is turned off from Settings App, but it is not working when Bluetooth is turned off from Control center e.g not showing the default Bluetooth popup.
Now I need to know if Bluetooth is turned off from the Control center so that I can show some custom popup message to the user.
Any help will be appreciated.
You are correct that the initialization option CBCentralManagerOptionShowPowerAlertKey, which should display a warning if the framework is initiated when bluetooth is turned off, does in fact not work as expected if bluetooth is toggled off from the Control Center. Since iOS 11 the system will actually not turn off bluetooth if you toggle off the button in Control Center, it only disconnects currently connected devices. The only way to turn off bluetooth then is to do it from System Settings. This is documented by Apple, but to me it is extremely misleading. So I honestly don't know if the API behavior you are experiencing is a bug, or if it is expected behavior.
My suggestion is that you skip this initialization option and instead rely on the value of central.state when you get the "centralManagerDidUpdateState:" callback and then create you own popup if the value is CBManagerStatePoweredOff, which oddly enough will be the case regardless if bluetooth is turned off from System Settings or if it is toggled off from the Control Center.
If your app works in the background you may want to use a local notification instead to get your user's attention.
Not a perfect solution, but it should be more reliable.
I have filed bug report 47516284 with Apple for this problem. Here's the text of the issue I filed.
I have noticed that the system alert notifying a user that an app needs Bluetooth will show when I turn off Bluetooth using the Settings app. I can use this system alert to go directly to bluetooth settings to turn it back on. However, when I turn off Bluetooth using Control center, there is no system alert that displays. This is problematic because although I can display a custom alert to tell the user to turn on Bluetooth, there is no way to code bringing the user directly to Bluetooth settings by tapping a button for instance. I believe the functionality should be consistent no matter how the user turns off Bluetooth.

GPS based VS Beacon based ranging? Which governs Lock screen left corner app icon

There are two approaches for showing an app/app suggestion (incase not installed) on the iphone lock screen / app switcher. One is GPS based, in which the IOS decides which app to show as a suggestion. Another is beacon based, in which a particular beacon is identified.
If location services are enabled for multiple apps and say all these apps are also using beacon based approach to show their icons on the lock screen left corner, which app icon will be shown by the IOS?
Since location services are enabled for these apps,and say there is another relevant app which is NOT using beacon based approach (using just the GPS based approach), can IOS give preference to beacon based apps over the GPS based this new app.?
For instance, Estimote’s NYC office is on the same block as an Equinox gym and our phones intelligently and automatically alert us to use that app. It’s super easy and intuitive to open the app while walking into the gym - and in the process, streamline the check-in flow with the gym’s front desk. However, because it solely uses GPS geofences, the accuracy is poor. We actually get the Equinox icon over 1 block away, and there is no control for the brands or stores (in this case Equinox) on how this appears.
Apple's suggestion of apps not installed on the phone based on proximity uses an undocumented technique. While I have verified it uses GPS as an input, I have never been able to confirm that beacons are used at all.
Regardless of whether beacons are used, because this is an undocumented feature, it is unlikely you will find a way to customize the behavior.
AFAIK, Apple has never shared the implementation details of how the lock screen icon AKA "suggested apps" feature works.
However, we did some experiments at Estimote and noticed that being inside a CLRegion (both the "GPS" CLCircularRegion, and CLBeaconRegion work) that an app monitors for via Core Location, consistently makes the app's icon show up on the lock screen. So it seems that both beacons and GPS location fall into the same mechanism that governs the location-based suggestions. (Note that in iOS 9, that's not just the lock screen icon, but also a bar at the bottom of the app switcher.)
Unfortunately, we weren't able to establish what happens if you're inside multiple qualifying CLRegions, belonging to different apps. We suspect it might have something to do with the order in which the apps register regions for monitoring, but were never able to get consistent results.
Furthermore, since this whole behavior is undocumented, Apple can change it at any time. Just something to be aware of.
Side note: handoff always trumps suggested apps.

Can you change the default Apple Watch watch?

I'm planning to make an watch app for the Apple Watch.
Is there any way of replacing the default home screen (or watch) of the device to be a custom watch?
Assuming there is none, the next best way would be to make a WatchKit App complete with with a Glance?
Does the apple watch come with a power saving mode by default where it will turn off the screen/running app reverting to it's home screen after a certain period of inactivity?
There is not at present any way to have a custom watch face. You could make an app with a glance view, but just to be clear a glance view cannot contain any buttons or interactive elements, it's just something to be looked at. If the user taps the glance it will open your watch app.

Changing the behavior of the iOS Lockscreen

Is there a way to change the behavior of the iOS Lockscreen? For instance, can an app, if active, provide a user with dynamic content, such as pictures, as the phone's background, and, in addition, allow a user to swipe left (in addition to swiping right, if they want to unlock the phone) to engage said content?
Is there a way to change the behavior of the iOS Lockscreen?
No.
For instance, can an app, if active...
No.
iOS doesn't provide any API that would allow the sort of thing that you describe. It might be possible to modify or replace the lock screen if you jailbreak your phone -- all bets are off at that point. But an app that uses the Apple-provided API has no way to modify the lock screen.
Also, note that if the device is locked, your app won't be active. You may have intended a looser definition of "active," but looking at the linked chart of app states will help you understand that what you're looking to do isn't achievable with the current API. Apps have to be active to receive events, but a locked phone implies that your app will be in an inactive, background, or suspended state if it's running at all.
No. (Not if you're talking about an 'app' in the sense of the App Store)
The only way an app can interact with the lock screen is through notifications, and cannot alter the standard lock screen interface.
You can alter the lock screen with a MobileSubstrate tweak on a jailbroken phone, but this requires reverse-engineering SpringBoard (the iOS launcher app), can be quite complicated and obviously cannot be distributed through the App Store

How can I edit the pairing alert view

I am developing an iOS 6 app that pairs with a custom BLE device.
When the user wants to pair, an alert message appears (directly form core bluetooth I guess) and the user can either push "Pair" or "Cancel".
However the title and body of the alert message are empty showing "PAIRING_TITLE" and "PAIRING_BODY".
How can I write a specific content for these two variables? Any idea?
As you guessed, that alert view is shown by the system and cannot be customized. I suppose it is the simulator that is causing those messages to be shown instead of some meaningful text. This can never happen on an actual device. Recommendation from Apple is not to use the simulator for development of BLE stuff. It is very likely that it won't be possible in the near future anyway.

Resources