iOS Question Push Notifications RemoteNotification event never runs

Hccsoft

Member
Licensed User
Longtime User
After compiling the push server, executing it from the windows cmd, and after sending a message from b4i with the "send" handle (Even when I debug push server I’ve got no error log):

cmd.png



After sending the token and then a message with the "send" handle, I get this in the b4i log:

upload_2018-1-15_18-40-38.png


These are the certificate, and provision file:

upload_2018-1-15_18-41-10.png


the fact is that I can not detect any errors but the debugger never stops in the Application_RemoteNotification event

these are the settings for notifications of the app:

notif.jpg




And this is the b4i code, can you tell me what I'm missing?

B4X:
'Code module
#Region  Project Attributes
   #ApplicationLabel: B4i Example
   #Version: 1.0.0
   #Entitlement: <key>aps-environment</key><string>production</string>
   'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
   #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
   #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
   #ProvisionFile: Push.mobileprovision
   '#PlistExtra: <key>UIBackgroundModes</key><array><string>remote-notification</string></array>
#End Region

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private Const ServerUrl As String = "http://192.168.1.40:51044"

End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   Dim but As Button
   but.Initialize("but",but.STYLE_SYSTEM)
   but.Text ="SEND PUSH"
   Page1.RootPanel.AddView(but,100,100,100,20)
   NavControl.ShowPage(Page1)
   App.RegisterUserNotifications(True, True, True)
   App.RegisterForRemoteNotifications
End Sub

Sub but_Click
   Dim job As HttpJob
   job.Initialize("jobsend", Me)
   'job.PostString(ServerUrl & "/send", "password=123" & "&text=Hello" & "&badge=1" & "&sound=piece.mp3")
   job.PostString(ServerUrl & "/send", "password=123" & "&text=Hello" & "&badge=1")
End Sub


Private Sub Application_PushToken (Success As Boolean, Token() As Byte)
   If Success Then
       Dim bc As ByteConverter
       Dim j As HttpJob
       j.Initialize("j", Me)
       j.PostString(ServerUrl & "/devicetoken", "token=" & bc.HexFromBytes(Token) & "&type=1")
   Else
       Log("Error getting token: " & LastException)
   End If
End Sub

Private Sub JobDone(j As HttpJob)
   If j.Success Then
       Log("Token uploaded successfully.")
   Else
       Log("Error uploading token")
   End If
   j.Release
End Sub

Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
   Log("Remote notification: " & Message)
   Dim m As Map = Message.Get("aps")
   Log(m)
   Log(m.Get("alert"))
   CompletionHandler.Complete
End Sub

'Private Sub Application_RemoteNotification (Message As Map)
'   Log("Remote notification: " & Message)
'   Dim m As Map = Message.Get("aps")
'   Log(m)
'   Log(m.Get("alert"))
'End Sub



Private Sub Page1_Resize(Width As Int, Height As Int)
 
End Sub

Private Sub Application_Background
 
End Sub
 

Attachments

  • upload_2018-1-15_18-40-14.png
    upload_2018-1-15_18-40-14.png
    69.4 KB · Views: 273
Last edited:

Hccsoft

Member
Licensed User
Longtime User
I recommend you to start from scratch with a new package name, new Firebase project and new provision profile + app id.

Hello Erel, yesterday I already created all the certificates again but I could not get any notification. This morning I sent one from the firebase console, and to my surprise the notification arrived. The most curious thing is that without doing anything when trying to send from the b4j sending tool, notifications have begun to arrive, maybe firebase needs some time to work after installation?
 
Upvote 0
Top