iOS Question Using native code, how can i implement callbacks to B4i subs?

ema01

Member
Licensed User
Longtime User
Before iOS 16 you were able to perform BLE scan and connect in the background using the B4i Ble Manager object from the iBLE library. Sure, an app would eventually be killed but depending on the situation you would have minutes/hours in which the application would still be able to perform its functions. Every update added new hoops you had to jump through but i always managed to find a solution.
However, since iOS 16 an application in background that is not performing a background task will be killed after a time between 10 and 30 seconds.
If you are connected to a BLE device and have declared the appropriate background modes, the app will not be killed, but you will not be able to perform scans and connects.

According to the documentation the correct way (since many iOS versions) to perform scan and connect is to use State Preservation and Restoration
If i understood it correctly, when you follow this method you have to register some callbacks that will be called for example when a new device will be in range (advertisement) and i have some time (10 seconds?) to decide what to do, if i want to connect to it. After which my application will be functioning (with no UI of course)

However, if i understand it correctly, there is no support for state preservation ad restoration in B4i, so the only thing i can do unless i want to write a native app is to reimplement the iBLE library, so write a bunch of native code and add it to my project. I see from the B4i -> ObjC translated files how the methods are implemented, great, i have a starting point, but then at some point i would want the native code to call a method in B4i. How do i do that? Besides testing the code in XCode and creating a library... I have a macbook but it's an old model i do NOT want to update to the latest OSX (if it's even possible) so i can use the XCode version that supports iOS 16
 
Top