Android Question everytime waiting app for FirebaseNotification

Tayfur

Well-Known Member
Licensed User
Longtime User
hello all;

I have a sample app. and it reading notify from firebase.
it s greate with @Erel code +lib.

but, App must be open(hide), it dont be exit.
I want to run evertime for Fbase.Notifitaions

I try ...

Serivce : starter
#StartAtBoot: True

but dont work it.
 

DonManfred

Expert
Licensed User
Longtime User
Dont set startatboot in the STARTER Service!
Use any other service and set the flag in this service to true.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Dont set startatboot in the STARTER Service!
Use any other service and set the flag in this service to true.
sorry @DonManfred
its dont work

ServiceName : FirebaseMessaging
B4X:
#Region  Service Attributes
    '#StartAtBoot: False
    #StartAtBoot: True
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
    'https://www.b4x.com/android/forum/threads/firebasenotifications-push-messages-firebase-cloud-messaging-fcm.67716/
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    fm.Initialize("fm")
    Log("fb service create")
End Sub


Sub Service_Start (StartingIntent As Intent)
    Log("fb service start")
    If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Log("app error")
    Return True
End Sub



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

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$) 
    Dim n As Notification
    n.Initialize
    n.Icon  = "icon"
    'n.SetInfo(Message.GetData.Get("tel"), Message.GetData.Get("adres"), Main)
    n.SetInfo("X-"&Message.GetData.Get("title"), "X-"&Message.GetData.Get("body"), Main)
    'n.SetInfo("X-"&Message.GetData.Get("title"), "X-xxxx", Main)
    n.Notify(1)
End Sub

Sub Service_Destroy
End Sub


Service Name : Starter

B4X:
#Region  Service Attributes
    '#StartAtBoot: False
 
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'Private fm As FirebaseMessaging
    'https://www.b4x.com/android/forum/threads/firebasenotifications-push-messages-firebase-cloud-messaging-fcm.67716/
    
End Sub

Sub Service_Start (StartingIntent As Intent)
    Log("Service_Start : Starter")
End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy
    Log("Service_Destroy : Starter")
End Sub
'Starter service

Sub Service_Create
    Log("Service_Create : Starter")
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
The app doesn't need to run in order to handle push messages. Just make sure to run it in Release mode and send the messages with the B4J program.

I cant do it :(

step by step
  1. #StartAtBoot: True (firebaseMasagiging Service),

  2. Starter service startatboot is none (delete#StartAtBoot:)
  3. compile realise mode
  4. Open app, after hide it. Test firebase message. Result is OK.
  5. Close/restart Phone
  6. Test firebase message. Resutl is NOT OK.
I checked the application permissions for startup App. ( I added manuelly)

I cant undersatnt it!! :(

Where is my error
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
You got this told by Erel days ago.
Your ignorance is great :mad:

Hello @DonManfred
I am ignorant in this regard. This is real. I would not ask questions if I knew.
I tried many times yesterday with Firebase console and B4J code .
The application did not work in both ways.
Today, app is work.
I have not changed anything in the code. I didnt open B4A today.
I do not know why the code did not work yesterday.
I do not know why the code works today. its maybe phone settings...
anyway, its working now.

you are
A very good programmer..
You have wonderful libraries...
You share everyone's information on the forum...

I believe that you are a good person. But your last message made me sad.
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
This issue I had with the device Lenovo Vibe K5, but worked perfectly on the Samsung Galaxy A9. I think Lenovo does a some of modding on standard Android to this device.
Mainly in background apps.
 
Upvote 0
Top