cordova -v): 8.1.2 ([email protected])cordova platform ls): android 7.1.4when i set "notificationsEnabled" to false (notificationsEnabled: false)
the notification is still visible
hidden local notifications
debug False working?
I am done with debug false but still hearing the beep sounds.
same problem here. the notificationsEnabled:false doesn't get rid of the local notification.
@mauron85 do you have a solution?
Same issue here, using alpha 50, Android, PhoneGap Build. Users are complaining at me, any help greatly appreciated.
Edit: fixed for now by downgrading to alpha.43.
Same issue using alpha 50.
When debug is enabled, the notification is still active. On the other hand, when debug is disabled and notificationsEnabled === null, an empty notification appears without displaying the title and text.
Same issue here, using alpha 50, Android, PhoneGap Build. Users are complaining at me, any help greatly appreciated.
Edit: fixed for now by downgrading to alpha.43.
really? I'll try tonight.
edit:
@CBC-G Downgrading to alpha.43 didn't work for me.
Could you tell me how you've configured the plugin?
BackgroundGeolocation.configure({
.........??
});
Your help would be greatly appreciated.
Current version of the app, using alpha 43:
BackgroundGeolocation.configure({
locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 1,
distanceFilter: 1,
maxLocations: 10,
notificationTitle: 'name of app',
notificationText: 'background task enabled',
debug: false,
startOnBoot: false,
stopOnTerminate: false,
stopOnStillActivity: false,
interval: 30000,
fastestInterval: 10000,
activitiesInterval: 10000,
url: controlURL + 'tracking',
syncUrl: controlURL + 'trackingfail',
postTemplate: {
lat: '@latitude',
lng: '@longitude',
id: currentShiftID,
xin: userID,
type: userType,
token: userToken
}
});
It seems alpha 50 was showing the notification on most but not all Android devices - had lots of reports coming in but didn't see it on my test phone. The previous version of the app had used alpha 43, so I added the "spec" to the line in config.xml:
<plugin name="cordova-plugin-mauron85-background-geolocation" spec="3.0.0-alpha.43" />
...and removed "notificationsEnabled: false" from the config as above (because I'd only added it to the latest version - I don't think it existed in alpha 43?), then recompiled in PhoneGap Build, and put it out as an update. Those were the only changes I made. The 2 users who checked it for me straightaway reported that they stopped getting the notification after updating, and I haven't had a single report of it since. (People had seen the crosshairs on the notification and were worried it was constantly tracking them when it shouldn't.) So I assumed it was just a bug introduced after alpha 43, and I'm confused if it didn't work for you - makes me wonder what the problem is then.
@mauron85 Hi !
A few days ago I saw in a .java file (I do not know which one) that there was a function
notificationIsEnable {
return notificationEnable! == null
}
Whether it is false or true, this test always returns true and will activate the notification. Can the problem come from this test?
Current version of the app, using alpha 43:
BackgroundGeolocation.configure({
locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 1,
distanceFilter: 1,
maxLocations: 10,
notificationTitle: 'name of app',
notificationText: 'background task enabled',
debug: false,
startOnBoot: false,
stopOnTerminate: false,
stopOnStillActivity: false,
interval: 30000,
fastestInterval: 10000,
activitiesInterval: 10000,
url: controlURL + 'tracking',
syncUrl: controlURL + 'trackingfail',
postTemplate: {
lat: '@latitude',
lng: '@longitude',
id: currentShiftID,
xin: userID,
type: userType,
token: userToken
}
});It seems alpha 50 was showing the notification on most but not all Android devices - had lots of reports coming in but didn't see it on my test phone. The previous version of the app had used alpha 43, so I added the "spec" to the line in config.xml:
<plugin name="cordova-plugin-mauron85-background-geolocation" spec="3.0.0-alpha.43" />...and removed "notificationsEnabled: false" from the config as above (because I'd only added it to the latest version - I don't think it existed in alpha 43?), then recompiled in PhoneGap Build, and put it out as an update. Those were the only changes I made. The 2 users who checked it for me straightaway reported that they stopped getting the notification after updating, and I haven't had a single report of it since. (People had seen the crosshairs on the notification and were worried it was constantly tracking them when it shouldn't.) So I assumed it was just a bug introduced after alpha 43, and I'm confused if it didn't work for you - makes me wonder what the problem is then.
doesn't work for me.
@mauron85 Hi !
A few days ago I saw in a .java file (I do not know which one) that there was a functionnotificationIsEnable {
return notificationEnable! == null
}Whether it is false or true, this test always returns true and will activate the notification. Can the problem come from this test?
in alpha.43 there isn't this line
but in /cordova-plugin-mauron85-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/Config.java
there is "return notificationsEnabled != null;".
The condition is right but notificationsEnabled seems always true(notification is always visible)
I can confirm that with alpha 50, using a configs with notificationsEnabled: null or notificationsEnabled: false both show notifications.
I think Config::getNotificationsEnabled() should change from:
@Nullable
public Boolean getNotificationsEnabled() {
return notificationsEnabled;
}
to (this is consistent with already-existing Config::isDebugging()):
@Nullable
public Boolean getNotificationsEnabled() {
return notificationsEnabled !== null && notificationsEnabled;
}
Note: setting startForeground: false fixes this problem enough for me though (the notification toast now only shows when the plugin is tracking in the background).
Thanks @mauron85 and all contributors for this amazing plugin!
@marcoandreac I think to fix notificationsEnabled: false, you need to change code located "\android\common\src\main\java\com\marianhello\bgloc\service\LocationServiceImpl.java" from:
@Override
public void startForeground() {
if (sIsRunning && !mIsInForeground) {
Config config = getConfig();
Notification notification = new NotificationHelper.NotificationFactory(this).getNotification(
config.getNotificationTitle(),
config.getNotificationText(),
config.getLargeNotificationIcon(),
config.getSmallNotificationIcon(),
config.getNotificationIconColor()
);
if (mProvider != null) {
mProvider.onCommand(LocationProvider.CMD_SWITCH_MODE,
LocationProvider.FOREGROUND_MODE);
}
super.startForeground(NOTIFICATION_ID, notification);
mIsInForeground = true;
}
}
to:
@Override
public void startForeground() {
if (sIsRunning && !mIsInForeground) {
Config config = getConfig();
if (mProvider != null) {
mProvider.onCommand(LocationProvider.CMD_SWITCH_MODE,
LocationProvider.FOREGROUND_MODE);
}
// *** Add notifications checker below ***
if (config.getNotificationsEnabled()) {
Notification notification = new NotificationHelper.NotificationFactory(this).getNotification(
config.getNotificationTitle(),
config.getNotificationText(),
config.getLargeNotificationIcon(),
config.getSmallNotificationIcon(),
config.getNotificationIconColor()
);
super.startForeground(NOTIFICATION_ID, notification);
}
mIsInForeground = true;
}
}
No. Notification is required for background geolocation to work reliably.
Check android docs.
@mauron85 Thanks for quick response. I know that, but for me who uses also cordova-background-mode by katzer, no need to be displayed second notification. So this option notificationsEnabled: false could be right fit to my goal. In current version of your plugin this option is not working. Or then I don't understand why this option needed?
notificationsEnabled is for disabling sync progress notifications. Not
sure about cordova-background-mode, it might work on some android versions
without displaying notification, but on never android versions, it is
required to run background location in long run.
@mauron85 I understand that notifications are necessary for Android. Is there a way we can get rid off beeping sound?
Just set debug: false
notificationsEnabledis for disabling sync progress notifications. Not sure about cordova-background-mode, it might work on some android versions without displaying notification, but on never android versions, it is required to run background location in long run.
from doc
notificationsEnabled: Enable/disable local notifications when tracking and syncing locations
so, is there a way to disable local notification?
@mauron85 thank you for your immediate response. Indeed, if debug: false, no beeps and no messages.
This is very issue for production apps.
How can solve it?
This appears when are few calls too.
What says specifically android doc?
I found this in BackgroundGeolocationFacade:247:
public void pause() {
mService.startForeground();
}
Shall we add a check there, for people voluntarily setting startForeground to false?
public void pause() {
if (getConfig().getStartForeground()) {
mService.startForeground();
}
}
@elgiano there was attempt to do that in https://github.com/mauron85/background-geolocation-android/pull/38
You'll find answer there.
@mauron85 Thanks! I see :(
So we have to live with the notification because we need a foreground service, otherwise the background service will be killed.
It makes sense, thanks for your work, it's great to see that this plugin is actively maintained :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.