Open SooChang-Lee opened 1 year ago
I have added the notification permission in AndroidManifest.xml
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
and have requested the permission with the "permission_handler" package.
Now the Notification Icon ist back and it seems that the tracking is working again correctly
@ibelz I'm facing the same issue. I added the permission and tried requesting it, just like you did. However, there's no dialog shown for me and on the app settings, it says:
This app does not send notifications
Do you know how to fix this?
I had the same problem, when starting the foreground service, the notification channel was configured but it was disabled by default, it only worked when manually activating from the application's notification settings.
As I understand it, in the source code, the channel is created with the importance "NONE", therefore it is not displayed.
What I did to fix it is to configure that same channel manually with the "flutter_local_notifications" plugin before starting the foreground service, so then the notification channel is now automatically activated.
This is a snippet of how it worked for me:
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
...
const AndroidNotificationChannel backgroundLocationChannel = AndroidNotificationChannel(
'geolocator_channel_01', // id
'Background Location', // name
description: 'Background Location Notification Channel', // description
importance: Importance.min,
);
final FlutterLocalNotificationsPlugin plugin = FlutterLocalNotificationsPlugin();
await plugin
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(backgroundLocationChannel);
In my case I was already using that plugin so I didn't have to add weight to my project.
Hi. Try specifying the service in your android manifest.
<service android:name="the.package.name" android:exported="true" />
Replace the.package.name with the background service package you are using
I was struggling with this issue, but i discovered it was simply that setOngoing was false by default in the ForegroundNotificationConfig. Setting it to true kept the foreground service alive even when the app went into the background. Hope that helps someone.
EDIT: sorry, i just realized this may be a totally different issue. Y'all may be talking about an actual notification that the user sees and not just the little "location" icon in the status bar that the system uses to indicate someone is using your location. Sorry for the confusion.
I'm trying to use Geolocator.getPositionStream() in the background to receive the position continuously for a long time even when the app is closed.
The problem is that notifications are visible on older devices, but not on newer devices.
It seems to be related to the answer in the url below. (Is my guess correct?)
https://stackoverflow.com/a/50634187
https://developer.android.com/about/versions/oreo/background#services
If the notification doesn't appear means the service isn't running as a ForegroundService normally, I'm afraid the service is being killed by the system.