iOS Question Push Notification Firebase not working....

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i always used Firebase to send notification to the apps...
i didn't know what i'm doing different, but i can't manage it to work.
What i did:
  1. Created App ID on Apple Dashboard
  2. Created Push notification SSL production certifcate
  3. Put it in the b4ikeys folder
  4. Created the AdHoc provision profile
  5. Generated the p12 firebase service file
  6. Created a project on firebase with the same package name, uploaded the p12 file
  7. put the googleplist.json in the Special folder
  8. added the Entitelment and ProvisionFile
  9. Imported the two firebase libraries and added all the Subs from the tutorial
The app compiles, the Sub fm_FCMConnected is fired, so it subscribe to "ios_general".
but when I try to send a notification using the B4J SendingTool to "ios_general" topic nothing arrives to my iphone....

I also tried an old application where push notification works, and i noticed that the Application_RemoteNotification is not fired anymore... i tried to put a log in it and it is not printed..



I tried also the approach with the Keys instead the Certificates.. same thing...

I don't know what to do

Thanks in advance
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Are you testing it when the app is in the background?
Are you using a distribution certificate?
Yes I tried also sending it in background and then run the b4j script

Yes I always use distribution certificate, in the b4i keys folder I have only that .cer
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
The only thing that I can say is that you missed something. Go over the tutorial. Post the logs. Make sure that you receive a push token.
So. i tried to make a blank project and it worked.
I made the same things in the real one.. and it does not work. (p.s. i deleted all the certificate, profiles, keys etc from Apple Dashboard and deleted the app from firebase project before try again. So this are all just created files. And i also changed the package id)

App ID:
with Push notifications enabled and the certificate (Sandbox and Production)
push notification.jpg

Ok

Provision Profile
Ok


Firebase console
with the p12 certificate uploaded (ignore the fact that there is also the keys, i tried them in different moment, even one at the time)
Ok

Google Plist
googleplist.jpg

Ok

Code
B4X:
#ProvisionFile: path/to/provision.mobileprovision
#Entitlement: <key>aps-environment</key><string>production</string>

Application_Start
B4X:
    App.RegisterUserNotifications(True, True, True)
    App.RegisterForRemoteNotifications
    fm.Initialize("fm")


B4X:
Private Sub fm_FCMConnected
    Log("FCMConnected")
    'here we can subscribe and unsubscribe from topics
    fm.SubscribeToTopic("ios_general") 'add ios_ prefix to all topics
End Sub

Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Log($"Message arrived: ${Message}"$)
    Msgbox(Message, "Push message!")
    CompletionHandler.Complete
End Sub

Sub Application_PushToken (Success As Boolean, Token() As Byte)
    Log($"PushToken: ${Success}"$)
    Log(LastException)
End Sub

Logs (i already sent the notification with b4j)
logs.jpg
 
Last edited:
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
. Go over the tutorial.
I tried again until now. recreating all certificates. i tried also to convert all the project to b4xpages (without firebase) and then add firebase in the end. nothing.. i got the same log, and the notification never arrives o_Oo_Oo_Oo_Oo_Oo_Oo_Oo_Oo_Oo_O
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Only you can solve it. Carefully follow the tutorial instructions and it will work.
It's very strange.. i did same exact things that i do usually. I tried in a blank project and it worked. i copy/pasted the same thigns in the orginal project and nothing work.
In the logs there is nothing useful, instead Firebase says connects succesfully and give me the token... everything seems just normal/working until i try sending notifications... i don't know where to start...
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Application_Start
B4X:
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
fm.Initialize("fm")


I found the problem:
analytics.initialize is missing ??? in the examples it was the very first line before even the NavControl... i completely missed it, embarassing. Im tired
 
Upvote 0
Top