My company has developed an App to control Bluetooth devices. I want to add a widget to display some information about my company's Bluetooth devices, such as battery level. In fact, I don't want to use the battery power of the system to display the battery power of my company's Bluetooth devices. What I want to ask is, can this function be achieved using WidgetKit? Can widgets added to the phone communicate with Bluetooth devices?
Is it possible to use WidgetKit to read Bluetooth device information, such as battery power?
Your question has sparked my interest: I have a number of BLE enabled apps, where battery level is of importance. Currently (pardon the pun) I check the level on app launch, but I can see the benefit of your approach in some of my circumstances. From reading the WidgetKit documentation I see no reason that a CoreBluetooth enabled class cannot be instantiated and executed within a TimelineProvider, assuming that the periodicity restrictions of WidgetKit are met. Any solution might need to use Combine to deal with the asynchronous nature of getting bluetooth responses. However, whether this would work with non-BLE (via External Accessory) I'm not so sure. Also, I'm not clear what you mean by "I don't want to use the battery power of the system". The Widget Extension will use the App device's resources to communicate with your bluetooth devices, but only at the time intervals (hourly?) set in the Timeline so it shouldn't be too much of a drain. If I get time I might experiment with one of my devices. Regards, Michaela
Thanks a lot. Because the system provides a widget of battery, in this widget, it can display the power of any Bluetooth device.Perhaps, you can also add a control of the Bluetooth device in the Widget of your own App. Try it, thanks.