sgrebnov / cordova-plugin-azure-notificationhub

Apache License 2.0
11 stars 36 forks source link

Android notifications does not received when app in the background #3

Open kant2002 opened 9 years ago

kant2002 commented 9 years ago

Currently application on Android does not receive notifications when it is not active. If I understand current design this is expected behavior. But I think that main use-case for push notifications is to notify user about application events when user outside of the app, where application could have different notification mechanisms. I have to manually modify your plugin to use WakefulBroadcastReceiver and IntentService to be able have desired functionality. When I implement I broke ability to handle notifications from JS part, since showing notification happens in the new IntentService which does not have CordovaWebView instantiated.

I see currently two way to improve current implementation.

  1. Add alternative implementation using WakefulBroadcastReceiver and IntentService and document how they could be enabled in the AndroidManifest.xml
  2. Instantiate CordovaWebView inside IntentService and load some limited subset of application inside that WebView. This is not very clear part for me and need discussion, but at least it could be starting point for discussion.

Not sure about iOS behavior, which I will check in next couple days and will post information for discussion.

I could provide patch with implementation which I have in my mind if needed.