Android Question A little confused about Push Notifications

FrostCodes

Active Member
Licensed User
Longtime User
Hello everyone, I have over 25k users I want to send push notifications to using FCM. I have implemented the example made by Erel and have been using it for some time now but I was very curious about something so I add my analytics tracking code to the event of when a new notification arrives. I noticed that even though in the past 30 days I have more than 6k active users, only about 490 received my push notifications. I thought this is weird as the example in the forum said that it would work both in foreground and background mode which I tested it but today I decided to sit down and test it with multiple phones, I tested it with android 7, 8 and I noticed that I only receive it when

1) The app is open currently
2) Or when I minimized or pressed the back button and the app is still in my recently open android app list.

I don't know if this is normal or not but my aim with push notifications was even if you just turned on your phone or haven't opened my app in a long time I can use it to make you remember about my app so I did something; I made a service that uses StartServiceAt() and auto-starts every 1 hour with the Firebase code :


B4X:
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")

and then I retested my app in release mode again and I quit it and even cleared the recently used app list and I pushed a notification with @Erel Fcm sending tool and the notification works perfectly well even without my app been opened at all.

So I am confused is something wrong with my first code or its normal and for what I want, it's better I use the second code to achieve it.
Thanks!

EDIT:

The first code I meant is EREL example .. here
and the second code is just the example but I added a new service that uses StartServiceAt to call the sub below every 1 hour
B4X:
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
 
Last edited:

FrostCodes

Active Member
Licensed User
Longtime User
1. Add a service with StartServiceAt that runs (for instance) every two hours
Hi yes, I tried this.. I made two services to restart and I set one to every 15 minutes and another to every 30 minutes... they both get killed and sometimes they don;'t even run at all. I even added that if the service was destroyed, they should restart but the same problem.

2. Check if Firebase service us running, and start it if needed
I logged this and yes at first it is running then suddenly after like 5 minutes of inactivity or the app been swiped, it stopped so I added a code to the app swipe event to call the firebase to subscribe sub and even restart my KillAlive service but the same thing... it get killed after sometime
3. Wait for a while (ten seconds?) to let Firebase do its thing
I left multiple phones brands running for hours to see if there was a delay but nope, no message entered in fact the topic I subscribed them all to is a new topic where all my other users aren't subscribed to so I wasn't expecting a delay!
4. If there's a push message received, do a phone.KeepAlive(true) to light the screen
Yes, I did use your code advice and unfortunately, it didn't help me
5. Give the phone OS a chance to display the notification (for ten seconds?)
Nothing ever happened at one point I even used sleep inside the code that would call the notification, the same problem.
6. Do a ReleaseKeepAlive
Yes I did this on the service destroyed event



Also thanks so much for your advice I really appreciate them it's just that I just couldn't make it work. At first the whole thing work but after some time it just doesn't I even used exactly Erel code and just edited my config and still the same issue!
 
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
The fact that your messages don't arrive after restarting the device means that you did something wrong. I recommend you to start from scratch and carefully follow the tutorial. Don't use PHP. Don't use Firebase Console.
I am tired of saying I used your code sample without any modification except to add my firebase id and config and it's the same issue. I give up on this issue if you keep thinking somehow it's my fault even though others are clearly facing the same issue. I tested the same code on about 8 phone brands that we use the most in my country all the same issues may be in your side the phone brands you use follows the android guideline properly and therefore the code runs fine for you but for me and my users, it doesn't.

There is no point arguing anymore I am done with this issue.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Also thanks so much for your advice I really appreciate them it's just that I just couldn't make it work
Sorry I couldn't help better to solve this.

Before you leave this issue, I have a couple of follow-up questions:
I used your code sample without any modification except to add my firebase id and config
1. Are you saying you used the exact B4J-SendingTool to send the messages, you just changed the firebase id and config?

I tested the same code on about 8 phone brands
2. To help future users (incl me), could you please list the exact brands and models of phones that you tested on? (If some of them are very local to your country and unknown to the rest of the world, it would be nice to add a link to the phone's product page if one exist.)
 
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
YES! I used exactly this.. I read the full article
I used Tecno[a tablet and a Phone - camon 11 pro and 15], Infinix, Oppo, Samsung, Gionee, Itel and Xiaomi)
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
So you tested and failed on these:

Tecno
Camon 11 Pro

Tecno
Camon 15

Infinix
No info om what model

Oppo
No info om what model

Samsung
No info om what model

Gionee
No info om what model

Itel
No info om what model

Xiaomi
No info om what model


Apart from Samsung (which I don't trust much) and Xiaomi, I've never heard of these brands. It would be very interesting to see your results if you tried one of the Google Pixel phones also: https://www.gsmarena.com/results.php3?sQuickSearch=yes&sName=google pixel (preferably a model made the last 3-4 years at least)
 
Last edited:
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
Unfortunately, I don't own the other phones so I can't really remember their models and I have returned them. and yes those are the phones you linked to.

As I said before, a standard google phone would probably run just fine. But there are other models which we use a lot here that are not running fine at all on and I linked to an article that explains this. We have Google Pixel here but very few people use it which means even if it's running fine on Pixel that would be less than 1% of all my users. This makes no sense for me to keep using it from a business perspective as it means I am losing users every day as I can't seem to remind them to use my app or engage with it. I hope you can understand what I am saying, this was why I said I don't want to waste more time on this issue and would move to use email and SMS marketing instead.

It's not like the push isn't working at all, it is but the issue is it only works on these devices when a user is using them and from a business perspective this makes no sense because the usage for us is we want to be able to interact with our users after they have stopped using our app or forgotten about it.


I said this here
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Yeah, I only suggested testing with Google Pixel to get some sort of "baseline" on how it works when the phone manufacturer doesn't deliberately strangle the device.

So my understanding of the situation is this: The push system works fine, just as Erel says. The problem is that your userbase use lots of brands where the manufacturer have crippled the devices so badly that push services (and probably other things in the phone also) just doesn't work as expected. If a company sells a potato and calls it a phone, you can't really assume push services will work on it.

The bottom line, as best as I can understand it, is that you're screwed by the phone companies and should - just as you already decided - switch to other means of communication for your users. :-/

Erel seems to have left this thread, but in case he's still around, it would be interesting to hear his thoughts on my description.
 
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
Exactly! Once again I appreciate your time and effort toward trying to help.
What I noticed and also read is the Chinese-based stock ROMs are mostly the ones with these issues. Unfortunately, nothing can be done that I know of as they prefer battery life to the proper functioning of our apps.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
I have just found this, perhaps it can be an additional item that one can consider. I'm not sure if it might address your issues, I am also testing it out as I have just received a video recording from a client complaining that they are not receiving notifications when the phone is "asleep". A very crucial part of the app.

Battery Optimization - Off
Set to receive all notifications - true
Long running timed service - On

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…