e-mission / e-mission-docs

Repository for docs and issues. If you need help, please file an issue here. Public conversations are better for open source projects than private email.
https://e-mission.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
15 stars 34 forks source link

android push notification not delivered to installed app #641

Open shankari opened 3 years ago

shankari commented 3 years ago

Just when I thought that I had a solution to determine when an app was uninstalled (see if a push notification is not delivered), push notifications to the Samsung Edge test device https://github.com/e-mission/e-mission-docs/issues/535#issuecomment-846635879

fail

combo token map has 0 ios entries and 1 android entries
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): fcm.googleapis.com:443
DEBUG:urllib3.connectionpool:https://fcm.googleapis.com:443 "POST /fcm/send HTTP/1.1" 200 None
DEBUG:root:{'ios': {'multicast_ids': [], 'success': 0, 'failure': 0, 'canonical_ids': 0, 'results': [], 'topic_message_id': None}, 'android': {'multicast_ids': [1991124429005606075], 'success': 0, 'failure': 1, 'canonical_ids': 0, 'results': [{'error': 'NotRegistered'}], 'topic_message_id': None}}
DEBUG:root:module_name = emission.net.ext_service.push.notify_interface_impl.firebase
DEBUG:root:module = <module 'emission.net.ext_service.push.notify_interface_impl.firebase' from '/usr/src/app/e-mission-server/emission/net/ext_service/push/notify_interface_impl/firebase.py'>
DEBUG:root:interface_obj_fn = <function get_interface at 0x7f2641c4d7a0>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f2642027810>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f2642027810>
DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 0 failure 1 results [{'error': 'NotRegistered'}]

And they have worked in the past (https://github.com/e-mission/e-mission-docs/issues/535#issuecomment-847503024) even when the app was sleeping, so this is definitely unexpected

shankari commented 3 years ago

killed app and relaunched in the hope that it would change the registration token. No luck.

INFO:root:After parsing, uuid list = [UUID('a2d48b05-d545-4d42-8c08-41432c7467b6')]
DEBUG:root:Getting tokens matching query {'user_id': {'$in': [UUID('a2d48b05-d545-4d42-8c08-41432c7467b6')]}}
DEBUG:root:adding token fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE to list for platform android
DEBUG:root:user_id_list of length 1 -> token list of length 1
DEBUG:root:module_name = emission.net.ext_service.push.notify_interface_impl.firebase
DEBUG:root:module = <module 'emission.net.ext_service.push.notify_interface_impl.firebase' from '/usr/src/app/e-mission-server/emission/net/ext_service/push/notify_interface_impl/firebase.py'>
DEBUG:root:interface_obj_fn = <function get_interface at 0x7f77cb2497a0>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f77cb248810>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f77cb248810>
INFO:root:iOS tokens are already in the FCM format, no mapping required
DEBUG:root:len(token_list) == 0, skipping fcm token mapping to save API call
after mapping iOS tokens, imported 0 -> processed 0
combo token map has 0 ios entries and 1 android entries
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): fcm.googleapis.com:443
DEBUG:urllib3.connectionpool:https://fcm.googleapis.com:443 "POST /fcm/send HTTP/1.1" 200 None
DEBUG:root:{'ios': {'multicast_ids': [], 'success': 0, 'failure': 0, 'canonical_ids': 0, 'results': [], 'topic_message_id': None}, 'android': {'multicast_ids': [5366665919118125462], 'success': 0, 'failure': 1, 'canonical_ids': 0, 'results': [{'error': 'NotRegistered'}], 'topic_message_id': None}}
DEBUG:root:module_name = emission.net.ext_service.push.notify_interface_impl.firebase
DEBUG:root:module = <module 'emission.net.ext_service.push.notify_interface_impl.firebase' from '/usr/src/app/e-mission-server/emission/net/ext_service/push/notify_interface_impl/firebase.py'>
DEBUG:root:interface_obj_fn = <function get_interface at 0x7f77cb2497a0>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f77ccbefdd0>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7f77ccbefdd0>
DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 0 failure 1 results [{'error': 'NotRegistered'}]

Will check the logs to see if the token matches. Might have to uninstall + reinstall?

shankari commented 3 years ago

Client token (registered just before that failure) seems to match:

26443,1622228315.796,2021-05-28T11:58:35.796000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
26446,1622228315.8370001,2021-05-28T11:58:35.837000-07:00,"js : Finished saving token = ""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"""

And it was working even when we came out of max power saving mode. https://github.com/e-mission/e-mission-docs/issues/535#issuecomment-849006691

But it's true that I don't think we have seen any notifications since then

shankari commented 3 years ago

I can also confirm that the token is the same that was assigned to the app when it was originally installed.

,ts,dt,message
0,1621808212.466,2021-05-23T15:16:52.466000-07:00,UnifiedLogger : finished init of android native code
1,1621808212.4689999,2021-05-23T15:16:52.469000-07:00,truncating obsolete entries before 1.619216212469E9
...
52,1621808220.61,2021-05-23T15:17:00.610000-07:00,"js : connectionConfigString = 
110,1621808247.456,2021-05-23T15:17:27.456000-07:00,"js : connectionConfigString = 
202,1621808274.873,2021-05-23T15:17:54.873000-07:00,PromptedAuth : About to execute script: window.cordova.plugins.BEMJWTAuth.launchPromptedAuth('Enter the anonymized token provided to you')
206,1621808332.856,2021-05-23T15:18:52.856000-07:00,JWTAuthPlugin : onNewIntent(...)
207,1621808332.863,2021-05-23T15:18:52.863000-07:00,PromptedAuth : received intent with url ...
210,1621808332.924,2021-05-23T15:18:52.924000-07:00,"ConnectionSettings : in getConnectURL, connectionSettings = ...
217,1621808333.5570002,2021-05-23T15:18:53.557000-07:00,"ConnectionSettings : in getConnectURL, connectionSettings = ...
222,1621808350.159,2021-05-23T15:19:10.159000-07:00,"ConnectionSettings : in getConnectURL, connectionSettings = ...
224,1621808350.177,2021-05-23T15:19:10.177000-07:00,"ConnectionSettings : in getConnectURL, connectionSettings = ...
237,1621808350.5279999,2021-05-23T15:19:10.528000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
241,1621808350.581,2021-05-23T15:19:10.581000-07:00,"ConnectionSettings : in getConnectURL, connectionSettings = ...
248,1621808350.6179998,2021-05-23T15:19:10.618000-07:00,"js : Finished saving token = ""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"""
shankari commented 3 years ago

Just to confirm:

server:      fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE
current app: fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE
app install: fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE
shankari commented 3 years ago

My best guess right now is that putting the phone into max power savings messed something up. Will play around for 10 mins with resetting the notifications but will continue with this next week.

shankari commented 3 years ago

Has been consistent throughout

kshankar-35069s:~ kshankar$ grep Token /tmp/2021-05-28_No_push_no_America_Los_Angeles.loggerDB.withdate.log
237,1621808350.5279999,2021-05-23T15:19:10.528000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
3946,1621819462.3179998,2021-05-23T18:24:22.318000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
4204,1621829983.187,2021-05-23T21:19:43.187000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
9870,1621911899.385,2021-05-24T20:04:59.385000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
10802,1621964960.5410001,2021-05-25T10:49:20.541000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
11412,1621974391.526,2021-05-25T13:26:31.526000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
12173,1621977363.843,2021-05-25T14:16:03.843000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
14658,1621991891.975,2021-05-25T18:18:11.975000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
15364,1622053054.8270001,2021-05-26T11:17:34.827000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
15722,1622055004.829,2021-05-26T11:50:04.829000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
16752,1622085423.407,2021-05-26T20:17:03.407000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
23284,1622132426.076,2021-05-27T09:20:26.076000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
26443,1622228315.796,2021-05-28T11:58:35.796000-07:00,"js : Token = {""token"":""fy3JFuzRMhM:APA91bG7RDChaP9Whbvi90D8E8MbPddu3C3LfaXICK7VNswyu8BAN8_fXhNFFM5p5EY6F5hGLTE7ahDr1BKnWkF7EEXBwUaIs90_k6kgG-FyHzYsI2sTCi7SgNo1GXXGjtEBe3vDRDVE"",""type"":""FCM""}"
shankari commented 3 years ago

Verified that there is nothing fundamentally wrong with android. Push notifications to other android phones do work

DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 1 failure 0 results [{'message_id': '0:1622242324465552%3997d08cf9fd7ecd'}]

DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 1 failure 0 results [{'message_id': '0:1622242360723760%3997d08cf9fd7ecd'}]
shankari commented 3 years ago

Confirmed that all notification permissions are turned on. Tried to turn them off and on, and we get the same error.

DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 0 failure 1 results [{'error': 'NotRegistered'}]

Will uninstall and reinstall after the long weekend.

All notifications turned on CanBikeCo turned on CanBikeCO turned on from app settings
Screenshot_20210528-155640 Screenshot_20210528-155714 Screenshot_20210528-155736
shankari commented 3 years ago

Note that this may be a general issue with Samsung phones, and we may not be able to rely on push notifications either!! https://eu.community.samsung.com/t5/galaxy-s20-series/s20-not-getting-notifications/td-p/1615189/page/2

Ditto. Seems to be a very long-standing bug across the Samsung range. There are threads here going back to the S8 last year all with the similar theme: Notifications simply stop working or are heavily delayed (minutes, hours, days). I have factory reset my phone 3 times, carefully reinstalled every app, tried each and every "fix" listed here and its still broken.

It's especially frustrating that this bug has affected S8, S9, S10 and S20 users for over a year now and Samsung don't even acknowledge it as a fault! I'm seriously thinking about invoking my consumer rights and returning the phone as faulty.

I've been testing with the app "Push Notification Tester" which on my S20 just spins and receives nothing. On my Lenovo tablet, my old Sony phone, basically every other device I can get my hands on, the notification is received within a second or two.

shankari commented 3 years ago

Could this be related to "optimized battery"

followed the video few of mine were in the optimised battery area so unchecked them but alas still no notifications, getting really frustrated with this so called flagship phone, going to downgraded back to my S9 soon I think.

Nope

DEBUG:root:firebase push result for android: success 0 failure 1 results [{'error': 'NotRegistered'}]
shankari commented 3 years ago

Turned off developer options, still doesn't work https://eu.community.samsung.com/t5/galaxy-s20-series/s20-not-getting-notifications/td-p/1615189/page/3

shankari commented 3 years ago

It automatically started working again after a week.

Attaching bugreport... bugreport-2021-06-08-21-27-10.zip