Jul 9, 2015 Replies: 25 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: Code: #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: Code: 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 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. Last edited: Dec 28, 2018 Click to expand...
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: Code: #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: Code: 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 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.
Erel B4X founder Staff member Licensed User Longtime User Apr 1, 2016 #21 Are you talking about the "This is a local notification" message? If you are seeing it then it means that your code was executed.
Are you talking about the "This is a local notification" message? If you are seeing it then it means that your code was executed.
marcick Well-Known Member Licensed User Longtime User Apr 1, 2016 #22 netkomm said: I used the source provided and placed the main.m file in the "Special" folder. Click to expand... This is not related to your problem, but note that with that file in the special folder the app will be rejected when trying to publish it to the store
netkomm said: I used the source provided and placed the main.m file in the "Special" folder. Click to expand... This is not related to your problem, but note that with that file in the special folder the app will be rejected when trying to publish it to the store
Erel B4X founder Staff member Licensed User Longtime User Apr 3, 2016 #23 marcick said: This is not related to your problem, but note that with that file in the special folder the app will be rejected when trying to publish it to the store Click to expand... This issue is fixed in v2.5.
marcick said: This is not related to your problem, but note that with that file in the special folder the app will be rejected when trying to publish it to the store Click to expand... This issue is fixed in v2.5.
marcick Well-Known Member Licensed User Longtime User Apr 3, 2016 #24 I'm updated, but last week I was publishing a new beta and it was rejected. I had to remove that file that I forgot in the special folder when I was doing experiments with silent notifications.
I'm updated, but last week I was publishing a new beta and it was rejected. I had to remove that file that I forgot in the special folder when I was doing experiments with silent notifications.
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2016 #25 Tutorial in the first post was updated. The custom main.m file is no longer required.
Erel B4X founder Staff member Licensed User Longtime User Oct 9, 2016 #26 Tutorial updated. It is now based on Firebase.