iOS Question How do i create a lock screen notification?

ema01

Member
Licensed User
Longtime User
Hi, i am porting an app from Android to iOS.
The App uses bluetooth and has to connect to the device the moment it comes in range. I have successfully been able to connect to the device when the app is in bacground so almost everything is sorted, the only thing it lacks is a notification on lock screen.

In the android version the is a persistent notification because the app is in foreground mode and while it seems that there is no such mode in iOS i'd still like to have a persistent notification in the lock screen (and also notification center? i'm not sure) as the notification serves two puroses: It shows the current status of the app (disconnected/connected in state x/y/z/...) and it tells the user that the os has not killed the application.

How do i do this in iOS? I'm not really familliar with the design phylosophy so maybe notification is not even the correct term..

In the android version i have used the NB6 library.

Thanks to all who can help me
Jacopo
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have successfully been able to connect to the device when the app is in bacground so almost everything is sorted
I don't think that it is possible (at least not with an app that goes to the app store). Your app will probably be killed after a few minutes.

Local notifications: Scheduling local notifications
 
Upvote 0

ema01

Member
Licensed User
Longtime User
Hm, i have tested it only on local devices without passing through the app store, but using the OTA deployer. It worked for several minutes.
I'll go on testing.

Anyway, thanks on the link, will read on and keep updating
 
Upvote 0

ema01

Member
Licensed User
Longtime User
First, in theory my app is allowed to run in background because i added
B4X:
#PlistExtra: <key>UIBackgroundModes</key><array><string>bluetooth-central</string></array>
however as soon as i started adding notifications i would occasionally have the app close while in background.

but if i remove the notifications it runs indefinetly (connects with the device as soon as it is in range, perform the operations without any issues)

second, i tried the local notifications but it's not exactly what i want. In Android i have this single notification that stays there as long as the app is active (when the app is first app is launched a service enters foreground mode) and i change the content of the notification to display the current status, like scanning for device, connected, please turn on bluetooth and such.

In iOS I wasn't able to change the content of the notification once it was registered, i had to register another notification but this meant of course that a new notification would pop up.

I also tried a bunch of apps and i think that soundcloud is the one that does what i want to do: when you start playing a song it will create a custom player in the notification area, above other notifications, that doesn't use the controls in the bottom drawer.

Is it possible to do something like that in B4i, a single notification -or whatever it's called- that lets me change its content, like a custom player? is a notification with actions a path to what i want to do? (see https://www.b4x.com/android/forum/threads/notifications-with-actions.100623/#content )
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…