iOS / WatchOS - Monitoring the connection between Apple Watch and iPhone - ios

I am trying to get a notification on iPhone when the connection is lost from my Apple Watch.
My first approach was to check the session.paired==true which works fine when the application is on foreground. But I would like to receive that event when the app is on background.
Then I thought about the Background Modes of the iOS and that there is a mode for external-accessorythat will send a notification on the device when is connected or disconnected. Is there something similar for watchOS?
My other idea is again with background modes and Bluetooth. Can you detect the watchOS as bluetooth?
Did anyone solve this issue?

Related

Can anyone give me an idea of how a bluetooth device like silent beacon can send a command to the phone while the screen is closed

I am talking the silentbeacon.com personal safety alarm device. How is it able to connect with the phone with bluetooth while the screen is locked. I am looking for an IOS solution.
Just because the screen is locked on the iOS device doesn't mean it cannot do any Bluetooth functionality. iOS devices have a special background mode that allows them to continuously read BLE adverts and also communicate with remote BLE devices. You can find more about this here:-
CoreBluetooth background processing for iOS apps
BLE device keeps connecting with iPhone when app terminates
iOS - BLE scan and connect to peripheral in background

Detect iPhone disconnected from WatchOS app in background

I’d like to know if there’s a way to detect if the iPhone is unreachable while the WatchOS app is in background. I tried to connect each other with CoreBluetooth but if WatchOS app is in background won’t call didDisconnected method.
So I tried the trick of update locations to get alive the app in the background, but everytime the Apple Watch screen awakes the WatchOS app is in foreground and the notification won’t works.
I implemented the
sessionReachabilityDidChange but neither this is called in background.
Can somebody give me a hint?
Or can tell me how to prevent the WatchOS app to be in foreground while update locations is running?

From WatchOS App connect BLE device using iPhone Bluetooth

Hi everyone here it's my problem, I have an simple app on my Apple Watch and iPhone. All my goal is using iPhone minimum on the App. Instead of iPhone App I want to use this App mostly from the watch. So I have an UI screen consisting with 2 buttons (Scan and Connect) on the watch. And these buttons should control the iPhone's Bluetooth. I don't want to use Watch Bluetooth. Considering all, is it posibble to trigger the iPhone Bluetooth in background from Watch and connect iPhone to a BLE device.
I think I fix this problem with your help guys;
Hi again, I believe I can fix this problem with the background transfers. Let me first explain the problem better when I want to use iPhone App local database and also want to use iPhone's Bluetooth from the Watch App I had trouble. And then I noticed sending messages from Watch to iOS wakes up iOS in the background (Source for more detail). In this way I'll have using iPhone app only in background and even scan BLE devices from the iPhone in bg and send them to the Watch App (WC Sessions).
Source (Communicate with iPhone and Watch)
https://medium.com/#jackywangdeveloper/apple-watch-communication-with-iphone-af84d51ff810

how to trigger notification from iPhone on iWatch

A noob question. I want to receive a notification when variable changes on the iOS app. to be clear. I want show notification on iWatch app when for example the user presses a button on the iOS App.
I have seen many tutorials for using the notifications interface. but all of them doesn't specify how to trigger the notifications from iPhone.
Anyone who knows a proper guide?
Thank you
Your notifications will go to your iPhone or your Apple Watch, depending on the device that you're using.
iOS will take care of notifications if your ios app supports notifications.
If your iPhone is unlocked, you get notifications on your iPhone, instead of your Apple Watch.
If your iPhone is locked or asleep, and your Apple Watch is unlocked and on your wrist, you get notifications on your Apple Watch.

ios background task notification for BLE devices

I'm developing a "background task enabled" app that connects to a BLE (bluetooth low energy) device. The user opens the app and connects to the BLE while the app is in the foreground. Once the app goes to the background it will keep communication open with the device (if in range) and be alert of any information received from such device. Now my question is how do I handle or even notice that data is coming from the device? It seems that right now my notifications are queued and are only shown when I manually bring the app to the foreground.
Thanks,
Andres N.

Resources