katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

background service is stopped working when new notification from background is added. #47

Closed Rahul6424 closed 9 years ago

Rahul6424 commented 9 years ago

Hi,

I am using

katzer/cordova-plugin-local-notifications and

katzer/cordova-plugin-background-mode But background service is using Foreground Notification and when my application goes in background and it receives any request from server it is producing a notification which clashes with the foreground Notification and my service stopped working.

i am using the following code for notification but LED is not showing any color.

window.plugin.notification.local.add({ led: 'A0FF05' }); also when my application goes on pause the background service is starting with huge error

12-23 13:54:08.180: E/ActivityThread(15572): Activity com.example.test.CordovaApp has leaked ServiceConnection de.appplant.cordova.plugin.background.BackgroundMode$1@426a9df8 that was originally bound here 12-23 13:54:08.180: E/ActivityThread(15572): android.app.ServiceConnectionLeaked: Activity com.example.test.CordovaApp has leaked ServiceConnection de.appplant.cordova.plugin.background.BackgroundMode$1@426a9df8 that was originally bound here 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:965) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ContextImpl.bindService(ContextImpl.java:1344) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ContextImpl.bindService(ContextImpl.java:1336) 12-23 13:54:08.180: E/ActivityThread(15572): at android.content.ContextWrapper.bindService(ContextWrapper.java:401) 12-23 13:54:08.180: E/ActivityThread(15572): at de.appplant.cordova.plugin.background.BackgroundMode.startService(BackgroundMode.java:241) 12-23 13:54:08.180: E/ActivityThread(15572): at de.appplant.cordova.plugin.background.BackgroundMode.onDestroy(BackgroundMode.java:154) 12-23 13:54:08.180: E/ActivityThread(15572): at org.apache.cordova.PluginManager.onDestroy(PluginManager.java:255) 12-23 13:54:08.180: E/ActivityThread(15572): at org.apache.cordova.CordovaWebView.handleDestroy(CordovaWebView.java:794) 12-23 13:54:08.180: E/ActivityThread(15572): at org.apache.cordova.CordovaActivity.onDestroy(CordovaActivity.java:649) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.Activity.performDestroy(Activity.java:5370) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1113) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3301) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3332) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ActivityThread.access$1200(ActivityThread.java:140) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280) 12-23 13:54:08.180: E/ActivityThread(15572): at android.os.Handler.dispatchMessage(Handler.java:99) 12-23 13:54:08.180: E/ActivityThread(15572): at android.os.Looper.loop(Looper.java:137) 12-23 13:54:08.180: E/ActivityThread(15572): at android.app.ActivityThread.main(ActivityThread.java:4898) 12-23 13:54:08.180: E/ActivityThread(15572): at java.lang.reflect.Method.invokeNative(Native Method) 12-23 13:54:08.180: E/ActivityThread(15572): at java.lang.reflect.Method.invoke(Method.java:511) 12-23 13:54:08.180: E/ActivityThread(15572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 12-23 13:54:08.180: E/ActivityThread(15572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 12-23 13:54:08.180: E/ActivityThread(15572): at dalvik.system.NativeStart.main(Native Method) Please tell me the solution for running application as a background service but without any foreground service or notification

Rahul6424 commented 9 years ago

@katzer Could you please look into this issue.

katzer commented 9 years ago

A Silent Mode has been added. Nevertheless local notifications and foreground notification can be used in combination!