Hello everybody
I have a small question. I am using Firebase to send notifications, can I somehow limit them in time? For example send / receive message from 8 am to 8 pm?
If you send data messages, there won't be an automatic notification. So you app must throw an own one. Here you can decide if it's the right time or store it to show it later.
Data message:
B4X:
Dim m As Map = CreateMap("to": $"/topics/${Top}"$)
Dim data As Map = CreateMap("data": datastring)
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.Tag=jg
Log(jg.ToString)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
If you send data messages, there won't be an automatic notification. So you app must throw an own one. Here you can decide if it's the right time or store it to show it later.
Data message:
B4X:
Dim m As Map = CreateMap("to": $"/topics/${Top}"$)
Dim data As Map = CreateMap("data": datastring)
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.Tag=jg
Log(jg.ToString)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
1. So you could throw a notification directly but without sound & light "at night" using the notification builder library (browse for it)
2. Store the messages at night to a file and if the user opens the app, show them.
3. Another one was to create a foreground service which has a timer. This keeps the device awake and consumes many battery power (not recommended) or Android will kill it. There ARE ways but as Android is user orientated (not a pc) not really waht you should do.
If you need more ideas, just post what kind of messages you process and what the user does with it (just read?)
If you send data messages, there won't be an automatic notification. So you app must throw an own one. Here you can decide if it's the right time or store it to show it later.