Closed sabeelmuttil closed 11 months ago
Currently notification is not receiving
Any code I can run to try this?
@X-SLAYER This is the code I'm trying to run.
Future<void> startListening() async {
/// check if notification permession is enebaled
bool status = await NotificationListenerService.isPermissionGranted();
if (!status) {
/// request notification permission
/// it will open the notifications settings page and return `true` once -
/// the permission granted.
status = await NotificationListenerService.requestPermission();
}
log('status $status');
/// stream the incoming notification events
NotificationListenerService.notificationsStream
.listen((ServiceNotificationEvent event) {
log('packageName $event');
if (event.hasRemoved != true) {
forgroundMessageHandler(event);
}
});
}
and this is the version I'm using
Flutter 3.13.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 12fccda598 (8 weeks ago) • 2023-09-19 13:56:11 -0700
Engine • revision bd986c5ed2
Tools • Dart 3.1.2 • DevTools 2.25.0
@X-SLAYER r u checked?
Did you try the example folder code? it works fine for me I tested it on a real device and an emulator + run the example code and check
same error ======== Exception caught by services library ====================================================== The following PlatformException was thrown while activating platform stream on channel x-slayer/notifications_event: PlatformException(error, com.payx.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts, null, null)
When the exception was thrown, this was the stack:
@X-SLAYER Could you pls publish the latest changes
WHat phone did you try one wich android version ?
emulator Pixal 3a Android 14
and also redmi note pro android 11 not working
i think it's problem with android 14 I will fix it asap
okay pls let me know once it is completed
Can you try the updated example folder before I publish the new version
@X-SLAYER Thanks this is working, but you need to change it a little bit
in android/build.gradle
compileSdkVersion 34
to
compileSdk 34
in onListen
context.registerReceiver(notificationReceiver, intentFilter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
context.registerReceiver(notificationReceiver, intentFilter, Context.RECEIVER_EXPORTED);
}else{
context.registerReceiver(notificationReceiver, intentFilter);
}
to
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
context.registerReceiver(notificationReceiver, intentFilter, Context.RECEIVER_EXPORTED);
}else{
context.registerReceiver(notificationReceiver, intentFilter);
}
New version is published notification_listener_service: ^0.3.3
@X-SLAYER In my case error showing like this