Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.24k stars 645 forks source link

[Bug]: ForegroundNotificationConfig.setOngoing has no effect, notification can be dismissed #1559

Open orkun1675 opened 3 weeks ago

orkun1675 commented 3 weeks ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

  1. Set AndroidSettings.ForegroundNotificationConfig.setOngoing = true
  2. Start a foreground service using getPositionStream()
  3. The service notification will appear as expected
  4. Try swiping left/right on the notification

Expected results

The notification can't be dismissed.

Actual results

The notification is dismissed / dissapears.

Code sample

Code sample ```dart [Paste your code here] ```

Screenshots or video

Screenshots or video demonstration [Upload media here]

Version

12.0.0

Flutter Doctor output

Doctor output ```console flutter doctor -v [✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-US) • Flutter version 3.24.0 on channel stable at /Users/orkun/git/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 80c2e84975 (3 weeks ago), 2024-07-30 23:06:49 +0700 • Engine revision b8800d88be • Dart version 3.5.0 • DevTools version 2.37.2 [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/orkun/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) [✓] VS Code (version 1.92.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.94.0 [✓] Connected device (4 available) ---- [✓] Network resources • All expected network resources are available. • No issues found!```
TimHoogstrate commented 3 weeks ago

Dear @orkun1675,

On what Android version are you testing this? Does this also happen on the supplied example app?

Kind regards,

orkun1675 commented 3 weeks ago

Hi Tim!

I am testing on a Pixel 8 Pro emulator that is running Android 35.

I was able to replicate the issue using the example app: source

orkun1675 commented 3 weeks ago

Hmm, it looks like Android no longer supports ongoing notifications after v34: https://developer.android.com/about/versions/14/behavior-changes-all#non-dismissable-notifications

What a bummer. Unfortunately neither the NotificationCompat.Builder or the Foreground services documentation mentions this.

I wonder if dimissing the notification kills the foreground service?

Stimm4 commented 2 weeks ago

Hi, I saw that deleting the notification did not kill the service.