Skip to content

Commit

Permalink
remove notification title
Browse files Browse the repository at this point in the history
  • Loading branch information
hchoga committed Nov 27, 2023
1 parent b311084 commit bbeb5d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 42 deletions.
6 changes: 1 addition & 5 deletions geolocator_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,8 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
useMSLAltitude: true,
foregroundNotificationConfig: const ForegroundNotificationConfig(
// Explain to the user why we are showing this notification.
notificationText:
"Example app will continue to receive your location even when you aren't using it",
// Tell the user what we are doing.
notificationTitle: "Running in Background",
// Keep the system awake to receive background location information.
enableWakeLock: false,
enableWakeLock: true,
// Give the notification an amber color.
color: Colors.amber,
),
Expand Down
17 changes: 4 additions & 13 deletions geolocator_android/lib/src/types/foreground_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class AndroidResource {
/// Configuration for the foreground notification. When this is provided the location service will run as a foreground service.
class ForegroundNotificationConfig {
/// The title used for the foreground service notification.
final String notificationTitle;

/// The body used for the foreground service notification.
final String notificationText;

/// The resource name of the icon to be used for the foreground notification.
final AndroidResource notificationIcon;

/// When enabled, a WifiLock is acquired when background execution is started.
/// This allows the application to keep the Wi-Fi radio awake, even when the
Expand Down Expand Up @@ -70,9 +70,7 @@ class ForegroundNotificationConfig {

/// Creates an Android specific configuration for the [FlutterBackground] plugin.
///
/// [notificationTitle] is the title used for the foreground service
/// notification.
/// [notificationText] is the body used for the foreground service
/// notification.
/// [notificationIcon] must be a drawable resource.
/// E. g. if the icon with name "background_icon" is in the "drawable"
Expand All @@ -89,10 +87,6 @@ class ForegroundNotificationConfig {
/// persistent and the user cannot dismiss it.
/// [color] is the accent color that is applied to the [notificationIcon].
const ForegroundNotificationConfig({
required this.notificationTitle,
required this.notificationText,
this.notificationIcon =
const AndroidResource(name: 'ic_launcher', defType: 'mipmap'),
this.enableWifiLock = false,
this.enableWakeLock = false,
this.setOngoing = false,
Expand All @@ -104,9 +98,6 @@ class ForegroundNotificationConfig {
return {
'enableWakeLock': enableWakeLock,
'enableWifiLock': enableWifiLock,
'notificationTitle': notificationTitle,
'notificationIcon': notificationIcon.toJson(),
'notificationText': notificationText,
'setOngoing': setOngoing,
'color': color?.value,
};
Expand Down
26 changes: 2 additions & 24 deletions geolocator_android/test/geolocator_android_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,8 @@ void main() {
useMSLAltitude: false,
foregroundNotificationConfig: const ForegroundNotificationConfig(
color: Colors.amber,
enableWakeLock: false,
enableWakeLock: true,
enableWifiLock: false,
notificationIcon: AndroidResource(
name: 'name',
defType: 'defType',
),
notificationText: 'text',
notificationTitle: 'title',
setOngoing: true,
),
);
Expand Down Expand Up @@ -1486,23 +1480,7 @@ void main() {
jsonMap['foregroundNotificationConfig']['enableWifiLock'],
settings.foregroundNotificationConfig!.enableWifiLock,
);
expect(
jsonMap['foregroundNotificationConfig']['notificationIcon']['name'],
settings.foregroundNotificationConfig!.notificationIcon.name,
);
expect(
jsonMap['foregroundNotificationConfig']['notificationIcon']
['defType'],
settings.foregroundNotificationConfig!.notificationIcon.defType,
);
expect(
jsonMap['foregroundNotificationConfig']['notificationText'],
settings.foregroundNotificationConfig!.notificationText,
);
expect(
jsonMap['foregroundNotificationConfig']['notificationTitle'],
settings.foregroundNotificationConfig!.notificationTitle,
);

expect(
jsonMap['foregroundNotificationConfig']['setOngoing'],
settings.foregroundNotificationConfig!.setOngoing,
Expand Down

0 comments on commit bbeb5d4

Please sign in to comment.