flutter-geolocator
flutter-geolocator copied to clipboard
Foreground notification data passed to ForegroundConfig are not being displayed
🐛 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:
late LocationSettings _locationSettings;
LocationSettings get locationSettings => _locationSettings;
Future<void> 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:
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
- give all the necessary permissions
- ensure location service is enabled on the phone
- subscribe to
GeoLocator.getPositionStreamand pass the location settings with custom foreground config - 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
Hi @nayefmazen,
I am also just setting up the plugin. I discovered that a wrong notificationIcon property caused my strings not being shown. Maybe the default icon that is set by the plugin is not present in your android folder?
@nayefmazen have u found solutions to this issue?