Hi, i'm trying to use Firebase to send Silent Push Notifications to my app.
The app, then, choose to show a notificaiton with LocalNotification or not.
The problem is that after a while the app is closed and no notification are coming for a while, when a new notification is sent it will never be received from the app (the event isn't raised)
What it could be?
The app, then, choose to show a notificaiton with LocalNotification or not.
The problem is that after a while the app is closed and no notification are coming for a while, when a new notification is sent it will never be received from the app (the event isn't raised)
B4X:
#Entitlement: <key>aps-environment</key><string>production</string>
'use the distribution certificate
#CertificateFile: ios_distribution.cer
'use the provision profile that goes with the explicit App Id
#ProvisionFile: NewsItalia/NewsItalia.mobileprovision
#PlistExtra: <key>UIBackgroundModes</key><array><string>remote-notification</string></array>
B4X:
Private Sub Application_Start (Nav As NavigationController)
Dim rl As ReleaseLogger
rl.Initialize("192.168.0.8", 54323)
analytics.Initialize
NavControl = Nav
NavControl.NavigationBarVisible = False
SetNavColors(Colors.White)
SplashScreenPg.Initialize("SplashScreenPg")
FileManager1.Initialize
SplashScreenPg.Title = "SplashScreen"
SplashScreenPg.RootPanel.LoadLayout("SplashScreen")
NavControl.ShowPage(SplashScreenPg)
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
App.ApplicationIconBadgeNumber = 0
firebaseMex.Initialize("firebaseMex")
End Sub
B4X:
Private Sub Application_Active
firebaseMex.FCMConnect 'should be called from Application_Active
End Sub
Private Sub Application_Background
firebaseMex.FCMDisconnect 'should be called from Application_Background
End Sub
Sub firebaseMex_FCMConnected
firebaseMex.SubscribeToTopic("ios_notificationsTEST") 'add ios_ prefix to all topics
firebaseMex.SubscribeToTopic("ios_articlesTEST")
End Sub
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
Log($"Message arrived: ${Message}"$)
'If Message.Get("topic") = "ios_notificationsTEST" Then
' Log("Notifications")
' MessageFromNotification(Message)
'Else
' Log("Articles")
' MessageFromArticles(Message)
'End If
MostraNotifica(Message)
CompletionHandler.Complete
End Sub
Sub MostraNotifica(Message As Map)
Dim ln As Notification
ln.Initialize(DateTime.Now)
ln.IconBadgeNumber = BADGENUMBER+1
ln.AlertBody = Message.Get("corpo")
If App.OSVersion >= 8.2 Then
Dim no As NativeObject = ln
no.SetField("alertTitle", Message.Get("titolo"))
End If
ln.PlaySound = True
ln.Register
NOT_LAST = DateTime.Now
FileManager1.AggiornaFile("Ultima_Notifica", NOT_LAST)
End Sub
What it could be?
Last edited: