This tutorial explains how you can use push notifications that don't show any visual cue to the user and start your app in the background for a limited time (up to 30 seconds).
You can use it for example to download new content.
Make sure to start with standard push notifications: https://www.b4x.com/android/forum/t...ions-push-messages-server-not-required.68645/
1. Add the remote notification background mode:
2. When a remote notification arrives the Application_RemoteNotification event will be raised. You have up to 30 seconds to do whatever your app needs to and then call CompletionHandler.Complete.
3. Sending code: remove the notification element and add the content_available field:
Note that you can add other fields to 'data' map.
Testing
iOS will not start the app automatically if the user has killed it. This makes it a bit difficult to test that it really works.
In order to test it you need to compile it in Release mode and run it once.
Now install the app again and do not start it. Send a silent push message and the process should start.
The app will not be visible. You can show a local notification to see that it is working.
You can use it for example to download new content.
Make sure to start with standard push notifications: https://www.b4x.com/android/forum/t...ions-push-messages-server-not-required.68645/
1. Add the remote notification background mode:
B4X:
#PlistExtra: <key>UIBackgroundModes</key><array><string>remote-notification</string></array>
2. When a remote notification arrives the Application_RemoteNotification event will be raised. You have up to 30 seconds to do whatever your app needs to and then call CompletionHandler.Complete.
3. Sending code: remove the notification element and add the content_available field:
B4X:
If Topic.StartsWith("ios_") Then
Dim iosalert As Map = CreateMap("title": Title, "body": Body, "sound": "default")
'm.Put("notification", iosalert) 'comment this line
m.Put("priority", 10)
m.Put("content_available", True) '<--- add
End If
Testing
iOS will not start the app automatically if the user has killed it. This makes it a bit difficult to test that it really works.
In order to test it you need to compile it in Release mode and run it once.
Now install the app again and do not start it. Send a silent push message and the process should start.
The app will not be visible. You can show a local notification to see that it is working.
Last edited: