flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Feature Request]: Add

Open DmitriySimonov opened this issue 1 year ago • 2 comments

Is there already an issue requesting this feature?

Please select affected platform(s)

  • [X] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Use case

  1. How can I change the channel name? I use different languages in the application, but here the channel name is automatically in English.

  2. How to find out the channel id? So that I can force close the notification!

Proposal

It's probably worth adding a setting to add your created channel for the current notification

изображение

Specific requirements or considerations

No response

Additional information or context

geolocator: ^11.0.0

[✓] Flutter (Channel stable, 3.16.9, on Ubuntu 22.04.3 LTS 5.15.0-94-generic, locale ru_RU.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
[✓] Connected device (3 available)
[✓] Network resources

DmitriySimonov avatar Feb 19 '24 13:02 DmitriySimonov

Dear @DmitriySimonov,

In order to help you, can you elaborate a bit on the subject? Can you for example share some of your code so that we can reproduce it? Can you also describe the steps to reproduce the case?

Kind regards,

Tim

TimHoogstrate avatar Feb 20 '24 10:02 TimHoogstrate

Dear @DmitriySimonov,

In order to help you, can you elaborate a bit on the subject? Can you for example share some of your code so that we can reproduce it? Can you also describe the steps to reproduce the case?

Kind regards,

Tim

    const LocationSettings locationSettings = LocationSettings(
      accuracy: LocationAccuracy.bestForNavigation,
    );
     Stream<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings);
     StreamSubscription<Position> positionStreamSubscription = _positionStream.listen((Position? position) async {
      //...
    });

DmitriySimonov avatar Feb 20 '24 11:02 DmitriySimonov

But did you enter the label "Background location" somewhere?

Kind regards

TimHoogstrate avatar Mar 05 '24 07:03 TimHoogstrate

But did you enter the label "Background location" somewhere?

Kind regards

No, it's a standardized creation

DmitriySimonov avatar Mar 05 '24 07:03 DmitriySimonov

Hi @DmitriySimonov,

Unfortunately we are not to familiar with these settings and how Android adds them. However this seems to be related to the Android notification settings.

Please try to use the AndroidSettings class instead of the LocationSettings class and specify detailed information for the foregroundNotificationConfig field. Something a long the lines of the following code sample:

late LocationSettings locationSettings;
if (defaultTargetPlatform == TargetPlatform.android) {
  locationSetting = AndroidSettings(
    accuracy: LocationAccuracy.bestForNavigation,
    foregroundNotificationConfig: const ForegroundNotificationConfig(
        notificationText:
        "Example app will continue to receive your location even when you aren't using it", // Translate this text into the appropriate language
        notificationTitle: "Running in Background", // Translate this text into the appropriate language
        enableWakeLock: true,
    ),
  );
} else {
  locationSettings = LocationSettings(
    accuracy: LocationAccuracy.bestForNavigation,
  );
} 

Please let us know if this helps.

mvanbeusekom avatar Mar 18 '24 08:03 mvanbeusekom

Hi @DmitriySimonov,

Unfortunately we are not to familiar with these settings and how Android adds them. However this seems to be related to the Android notification settings.

Please try to use the AndroidSettings class instead of the LocationSettings class and specify detailed information for the foregroundNotificationConfig field. Something a long the lines of the following code sample:

late LocationSettings locationSettings;
if (defaultTargetPlatform == TargetPlatform.android) {
  locationSetting = AndroidSettings(
    accuracy: LocationAccuracy.bestForNavigation,
    foregroundNotificationConfig: const ForegroundNotificationConfig(
        notificationText:
        "Example app will continue to receive your location even when you aren't using it", // Translate this text into the appropriate language
        notificationTitle: "Running in Background", // Translate this text into the appropriate language
        enableWakeLock: true,
    ),
  );
} else {
  locationSettings = LocationSettings(
    accuracy: LocationAccuracy.bestForNavigation,
  );
} 

Please let us know if this helps.

What you sent, there is no channel name setting there Please read the article

https://developer.android.com/develop/ui/views/notifications/channels

DmitriySimonov avatar Mar 18 '24 11:03 DmitriySimonov

Hi @DmitriySimonov,

Thank you for supplying the additional link. This helped me find the location where the channel is set. I noticed indeed that the channel name is hardcoded to "Background Location" in our code base.

I will start a bug fix which will add an additional channelName parameter to the AndroidSettings class which can be used to override the channel name.

mvanbeusekom avatar Mar 18 '24 12:03 mvanbeusekom

Thank you for your work! Looking forward to updates 👍

DmitriySimonov avatar Mar 18 '24 12:03 DmitriySimonov