taivo / parse-push-plugin

Push notification plugin for Cordova/Phonegap/ionic on Parse platform
118 stars 102 forks source link

Notifications not being received by Android app when phone has low memory - need a START_STICKY ? #131

Open budda opened 5 years ago

budda commented 5 years ago

For some users, we've heard that they don't receive the push notifications to their phone when the app is running in the background quietly.

As far as we know it is only an issue for Android devices, iOS is fine.

From doing some research this might be caused by the initial push notification service initialization.

According to https://stackoverflow.com/questions/9093271/start-sticky-and-start-not-sticky#9441795 Android will kill off services when memory is low, and then depending on a flag will later attempt to restart services when memory is available by calling onStart() method.

From an initial review of ParsePushApplication.java code it would suggest that all the initialization code happens in the onCreate() method, meaning AndroidOS re-calling onStart() after terminating running services would do nothing... resulting in the app not handling any notifications.

I'm not too familiar with the Android Java code so would welcome any thoughts or feedback on the above assumptions to a possible cause of notification silence we see on some users phones.

budda commented 5 years ago

Could Android 6 / API level 23 Doze be causing a problem in relation to messages not getting through for some users too? https://developer.android.com/training/monitoring-device-state/doze-standby