DavidBriglio / cordova-plugin-foreground-service

Foreground service with ongoing notification for Android.
MIT License
39 stars 40 forks source link

foregroundService is not started #14

Closed ekohadim closed 4 years ago

ekohadim commented 4 years ago

Hi, i am trying this plugin on VueJS. For some reason, the service is not started, i've put this line cordova.plugins.foregroundService.start('GPS Running', 'Background Service', 'icon', 3, 10);

Nothing happened, not shown any notification, so i'm not sure if the service does really run. But the cordova.plugins.foregroundService does exist when i debug it like the following.

image

I am using cordova 9.0.0 Would you mind telling me the issue?

DavidBriglio commented 4 years ago

Hello, what device are you running this on and what android version is it using? Also please try the start method with 2 parameters to see if it runs: cordova.plugins.foregroundService.start('GPS Running', 'Background Service').

ekohadim commented 4 years ago

I am running it on Xiaomi Redmi 4x, Android version 7.1.2. I've tried running as suggested with 2 parameters, still no luck. Any other idea?

DavidBriglio commented 4 years ago

This plugin is for use with android API 26+ (Starting at android version 8.0) and does not support lower versions due to the nature of the plugin. What are you trying to accomplish by using this plugin, maybe I can point you in the right direction?

ekohadim commented 4 years ago

Ok, my bad. I will try on android 8.0+. I was trying to run BackgroundGeolocation, but it stops after few minutes. I have to use PowerOptimization and the app will ask the user to set the power save mode to No Restriction. It runs okay, but if can be done without setting up that power save mode would be better. Thanks heaps for your response.

DavidBriglio commented 4 years ago

No problem! If you must support android API 25 and lower, you may want to look at how to implement the older foreground service in android. It would be a similar method to what this plugin is doing except using older api calls.