Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a feature to disable notifications on Android #10

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

danielgindi
Copy link
Contributor

Not everyone wants the library to force those notifications on them. There are other ways to convey to the user that the app is tracking in the background.

I have kept the original default where notifications are enabled, and it's an opt-out feature.
Set notificationsEnabled: false to disable local notifications.

Also closes:
mauron85/react-native-background-geolocation#242

@mauron85
Copy link
Owner

What kind of notifications does this affect? I only see upload notification when syncing locations.

@danielgindi
Copy link
Contributor Author

This affects all notifications. So when disabling notifications - even upload notifications should not be visible

@danielgindi
Copy link
Contributor Author

Did you see a notification that this did not disable? (Other than debug: true notifications?)

@mauron85
Copy link
Owner

You're disabling upload notifications - that's OK

But on https://github.com/mauron85/background-geolocation-android/pull/10/files#diff-39da09e20c965706fa858ed7384be0fdR339 you're only disabling changes to service notification.

The notification will still be present. Don't think that's what you intended.

Anyway removing service notification is bad thing, it will make service unreliable.

@danielgindi
Copy link
Contributor Author

Well if the notification did not exist at the time of the update to the notification, it will create it. To my understanding this is what the NOTIFICATION_ID ensures.

@danielgindi
Copy link
Contributor Author

Now I got your point. This is the "foreground" service notification. Android requires it to make the service foreground...

So I'm going to make a change, to make notificationsEnabled only for the other notifications (like sync notifications).
And this one should be less annoying to oreo users anyway because we removed the sound of it, so it will not get crazy with sounds every time the app goes to foreground or background...

@danielgindi
Copy link
Contributor Author

Done

@mauron85
Copy link
Owner

This looks OK, but why did you commented out tone generator?

@danielgindi
Copy link
Contributor Author

I think it's a residue from by debugging to see that no sounds were raised, I'll fix it right away

@danielgindi
Copy link
Contributor Author

Done

@mauron85 mauron85 mentioned this pull request Aug 22, 2018
@mauron85 mauron85 merged commit 4f2e3b9 into mauron85:master Aug 23, 2018
@mauron85
Copy link
Owner

Merged. Thank you!

@danielgindi danielgindi deleted the feature/notificationsEnabled branch August 24, 2018 10:46
@mcmar
Copy link

mcmar commented Sep 12, 2018

@mauron85 @danielgindi If I want to actually run in the background, can this library let me? I understand what I'm doing and I'm ok with receiving updates only a few times an hour. Our Android users are paranoid and deleting the app in huge numbers. We'd rather have infrequent location updates than zero Android users.

@danielgindi
Copy link
Contributor Author

Please read the docs, especially on the several providers available.
In short, yes you can.
If you expect trust issues - you should be clear about what you send to your servers, when you send it, how long are you planning on keeping it, and what you are going to do with it.
For being honest with your users there's the feature of the foreground notification in Android, which stays there as long as you are tracking location.

@mcmar
Copy link

mcmar commented Sep 12, 2018

Thank you very much @danielgindi .
We make sure to let our users know what information we collect and what we use it for. All of our users are crystal clear that we're a location-based social app.

It looks like the app always runs in Android as a "foreground service" as opposed to a background service. I'm commenting here because there was discussion about disabling the "foreground" notification.
See this comment: #10 (comment)

I'm trying to disable the "foreground service" notification, even if that means dealing with the strict limitations that Android 8 Oreo places on background services. Is that possible with this library? I know that it was on an older version before "experiemental oreo support" was added.

For reference, here is my config:

    BackgroundGeolocation.configure({
      // all
      locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
      desiredAccuracy: BackgroundGeolocation.LOW_ACCURACY,
      stationaryRadius: dist,
      distanceFilter: dist,
      debug: false,
      stopOnTerminate: false,

      // android
      startOnBoot: true,
      // startForeground: false,
      notificationTitle: '<FOREGROUND_SERVICE_NOTIFICATION_TITLE>',
      notificationText: '<FOREGROUND_SERVICE_NOTIFICATION_TEXT>',
      interval: 60000,
      fastestInterval: 60000,
      activitiesInterval: 60000,
      stopOnStillActivity: false,

      // iOS
      pauseLocationUpdates: false,
      saveBatteryOnBackground: true,
    });

@mauron85
Copy link
Owner

I'm trying to disable the "foreground service" notification, even if that means dealing with the strict limitations that Android 8 Oreo places on background services. Is that possible with this library? I know that it was on an older version before "experiemental oreo support" was added.

It's not possible anymore to keep location updates running in the background and having no visible notification. The reasons are exactly those mentioned here by you and @danielgindi.

  1. privacy of users
  2. android 8.0 limitation for background processes

@danielgindi
Copy link
Contributor Author

Android 8 works with scheduled Jobs now, no background services.
Foreground service is the most positive way to go about it in Android, not only in 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants