Baseflow / Baseflow/flutter-geolocator

Foreground notification data passed to ForegroundConfig are not being displayed

Open
#1,060 3 comments 0 reactions 0 assignees View on GitHub
P2 platform: android type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

## 🐛 Bug Report

I am passing a custom foreground config in locationSettings for android, basically I am changing the notification title and notification text. However, the notification title and text are not changing to the values being passed. Here is a code sample of what I am doing:

setting the location settings:
```dart
late LocationSettings _locationSettings;
LocationSettings get locationSettings => _locationSettings;

Future setupLocationServiceStatus() async {
await refreshStatuses();
if (defaultTargetPlatform == TargetPlatform.android) {
_locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
intervalDuration: const Duration(seconds: 5),
foregroundNotificationConfig: ForegroundNotificationConfig(
notificationTitle: LOCATION_NOTIFICATION_TITLE,
notificationText: LOCATION_NOTIFICATION_DESCRIPTION,
),
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
_locationSettings = AppleSettings(
accuracy: LocationAccuracy.high,
showBackgroundLocationIndicator: true,
);
}
}
```
subscribing to the get position stream:
```dart
locationStreamSubscription = Geolocator.getPositionStream(
locationSettings: LocationService.getInstance().locationSettings,
).listen((Position? position) async {
if (position == null) return;
currentLocation = LatLng(position.latitude, position.longitude);
MainServicesStream.addLocationEvent(
UserMovedMapEvent(currentLocation!),
);
});
```

### Expected behavior
expected behaviour is to update the notification title and text to the data being passed

### Reproduction steps
1. give all the necessary permissions
2. ensure location service is enabled on the phone
3. subscribe to `GeoLocator.getPositionStream` and pass the location settings with custom foreground config
4. stream is working fine but the foreground notification not showing the details that have been passed in step 3

### Configuration
I am testing on a samsung s21 FE with android 12
flutter details:
```
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.1 21C52 darwin-arm, locale en-GB)
• Flutter version 3.0.0 at /Users/nayefradwi/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ee4e09cce0 (5 days ago), 2022-05-09 16:45:18 -0700
• Engine revision d1b9a6938a
• Dart version 2.17.0
• DevTools version 2.12.2
```

**Version:** 8.2.1

**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android

Contributor guide

Open the contributing guide

Research direction

Start at the AndroidSettings and ForegroundNotificationConfig passed to Geolocator.getPositionStream, then trace how the foreground notification is created and updated. Reproduce the stream setup on Android 12 and verify that the configured notification title and text are displayed.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.