Android Question FirebaseNotification Error

Tasyo28

Member
Licensed User
Hi,

I'm creating a notification using Firebase Messaging but apparently this error is coming after i send message to app.

Also i already add this to manifest
-Google Play Services Base
-Firebase Base
-Firebase Notifications

after i sent the message in firebase console or in PHP url, the application is crushing "Unfortunately, Test has stopped"

Please help and advise thanks alot

upload_2017-12-22_0-12-52.png


and this is my code
B4X:
#Region  Project Attributes 
    #ApplicationLabel: Test
    #VersionCode: 1
    #VersionName: 
    #additionaljar: com.android.support:support-v4
    #BridgeLogger: true
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Public fm As FirebaseMessaging
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub



Sub Service_Create
   fm.Initialize("fm")
    CallSubDelayed(fm, "SubscribeToTopics")
End Sub

Public Sub SubscribeToTopics
   fm.SubscribeToTopic("general") 'you can subscribe to more topics
   
End Sub

Sub Service_Start (StartingIntent As Intent)
   If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
   'Log("Message arrived")
    'Log($"Message data: ${Message.GetData}"$)
    Dim nb As NotificationBuilder
    nb.initialize
    nb.SmallIcon = "icon"
    nb.Ticker = "Ticker"
    nb.ContentTitle = "Title"
    nb.ContentText = "Text"
    nb.ContentInfo = "Info"
    nb.SubText = "SubText"
    nb.OnGoingEvent = True
    nb.Notify(1)
End Sub
   


Sub Service_Destroy

End Sub
 

An Schi

Well-Known Member
Licensed User
Did you follow step 2?

2. Add a Service named FirebaseMessaging to your app (must be this name)
 
Upvote 0

Tasyo28

Member
Licensed User
Hi An chi,

Thank you for your reply, actually I'm very new in B4a and the step you said is the one i dont know how to write in the code.

Can you please tell me where and how to code to add service named FirebaseMessaging? Thanks
 
Upvote 0

Tasyo28

Member
Licensed User
Hi An chi,

I got it thank you very much.

This is my problem now, each devices that will install my app will have defferent unique tokens which is i used to send a message using PHP.

Do you have any suggestions or samples how can i store all devices unique tokens and send them all message at once? or devices will automatically subscribe then automatically when i send message via php all of the devices will receive?

Thanks
 
Upvote 0
Top