Android Question Push & old app

fishwolf

Well-Known Member
Licensed User
Longtime User
I have notice that 2 my old apps never updated, today receive the push only if the app is in backbround, before work fine
It's changed something with android 7 or other?

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
If the targetSdkVersion is less than 26 then the old app should work. That is unless it is not configured properly or you are not sending the messages properly.

i'm tring the notification with a test app and firebase, vba 8.00 and last sdk.
but i have the same problem, i receive notification only with app in background
 

Attachments

  • Test.zip
    9.3 KB · Views: 169
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
1. Starter service should never be started at boot.

2. You need to update the code: https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/

3. Start with a topic named "general"

4. Are you sending the message with the B4J code?

1. Ok, also "FirebaseMessaging" service never started at boot?

2. Done

3. Done, i have use also token

4. Done with firebase panell and B4J code

But the problem it's tha same, the push work fine only with app in background

i have a ASUS zenphone 3 with android 7
 
Last edited:
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Log cat:
B4X:
05-04 16:37:49.566 862-2039/? D/PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="GOOGLE_C2DM", packageName=com.google.android.gms, ownerUid=10030, ownerPid=1827, workSource=WorkSource{10159 firebase.test}
05-04 16:37:49.569 862-11061/? V/ActivityManager: Broadcast: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=firebase.test (has extras) } ordered=true userid=0 callerApp=ProcessRecord{83e2a4e 1827:com.google.android.gms.persistent/u0a30}
05-04 16:37:49.571 862-952/? W/BroadcastQueue: Reject to launch app firebase.test/10159 for broadcast: App Op 69
05-04 16:37:49.574 1827-1827/? W/GCM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=firebase.test (has extras) }
05-04 16:37:49.576 862-2032/? D/PowerManagerNotifier: onWakeLockReleased: flags=1, tag="GOOGLE_C2DM", packageName=com.google.android.gms, ownerUid=10030, ownerPid=1827, workSource=WorkSource{10159 firebase.test}
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your projects are fine. I'm able to send and receive messages with your projects, after changing the package name and the server key.

Note that you are using the old server key in the "Send" project. The new one should be much longer.

If it doesn't work for you with the new server key then try to create a new firebase project.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Your projects are fine. I'm able to send and receive messages with your projects, after changing the package name and the server key.

Note that you are using the old server key in the "Send" project. The new one should be much longer.

If it doesn't work for you with the new server key then try to create a new firebase project.

Done
1) Create a new project
2) Change the name project
3) Use server key long for send push
the problem it's the same, only in backgroup i can receive the push notification.

Note:
With a old Samsuns S3 work fine
On Asus Zenphone 3 (Android 7), from log cat i see the push arrived, but is rejected
On Huawei P8 Lite (Android 6) the same.


But this push notification are reliable?
I'm thinking to custom notification :)

B4X:
5-08 11:28:25.774 853-2032/? D/PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="GOOGLE_C2DM", packageName=com.google.android.gms, ownerUid=10030, ownerPid=1836, workSource=WorkSource{10163 firebase.test2}
05-08 11:28:25.777 853-1437/? V/ActivityManager: Broadcast: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=firebase.test2 (has extras) } ordered=true userid=0 callerApp=ProcessRecord{354a7d5 1836:com.google.android.gms.persistent/u0a30}
05-08 11:28:25.779 853-956/? W/BroadcastQueue: Reject to launch app firebase.test2/10163 for broadcast: App Op 69
05-08 11:28:25.783 1836-1836/? W/GCM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=firebase.test2 (has extras) }
05-08 11:28:25.785 853-4513/? D/PowerManagerNotifier: onWakeLockReleased: flags=1, tag="GOOGLE_C2DM", packageName=com.google.android.gms, ownerUid=10030, ownerPid=1836, workSource=WorkSource{10163 firebase.test2}
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Only now I understand what you meant in the first post. I thought that you don't receive notifications when the app is in the foreground.

Some devices will not let your app start implicitly after the user kills it from the recent apps list, especially if you killed the app multiple times.

I'm thinking to custom notification
It will only be less reliable.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Some devices will not let your app start implicitly after the user kills it from the recent apps list, especially if you killed the app multiple times.

ok, but other apps (gmail, facebook, whatapp, ecc,ecc) on Asus/Huawei show the notification also when are closed.
for which it's a problem of permissions or other of specific B4A app.
For have high impression on banner is very important be sure that the notification are reliable
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
for which it's a problem of permissions or other of specific B4A app.
For have high impression on banner is very important be sure that the notification are reliable
It doesn't matter if you write the app with B4A or Java. The behavior will be identical.

The fact that your device doesn't let your app start after it was killed doesn't mean that your app will not receive notifications while it is not running. It means that the OS decided that your app should not be started until the user explicitly starts it.
Possible causes:
- It crashed a lot while you debugged it.
- You explicitly killed it many times. This is not the correct way to test the behavior. You should let the OS kill it after a while or restart the device.

Don't compare your app to gmail, facebook and other very popular apps. Some devices treat those apps differently.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Don't compare your app to gmail, facebook and other very popular apps. Some devices treat those apps differently.

Good, series A app and series B app :)

i have run the app, received a push and set in background.
After 24 hours i have also the app in background, but don't receive push, receive push only if set app in foreground for a second.

If i reboot the device don't receive the push

in conclusion from my statistics the push are received only from 40% of registred devices, i'm thinking to use a MQTT protocol
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
i'm thinking to use a MQTT protocol
It will not help at all. The problem is this:

05-08 11:28:25.779 853-956/? W/BroadcastQueue: Reject to launch app firebase.test2/10163 for broadcast: App Op 69

The OS prevented your app from starting. Test it with a different package name and avoid explicitly killing the app.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Test it with a different package name and avoid explicitly killing the app.

done, the same problem
i have tried to use ExitApplication for close the app, Activity.finish set the app in background

B4X:
05-10 14:47:31.729 869-920/? W/BroadcastQueue: Reject to launch app com.company.news.blog/10164 for broadcast: App Op 69
 
Upvote 0
Top