Closed slice-mohit closed 2 years ago
@slice-mohit
Can you provide code for requestPermission()
? Does the same behavior occur on a real device too ?
Also, can you try the plugin example on same emulator and on real device and see if you get same behavior or not ?
@darshankawar Here is requestPermission. It just calls requestPermission of package and logs the status.
static Future<void> requestPermission() async {
final settings = await _fcm.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
log('User granted permission: ${settings.authorizationStatus}');
}
Haven't tested on real device. Will let you know after running the example code.
${settings.authorizationStatus}');
What does this print when the permission dialog doesn't show up at first ? as compared to when it does ?
Also, can you uninstall app, compile and run again and observe what does the authorizationStatus
returns ?
What does this print when the permission dialog doesn't show up at first ? as compared to when it does ?
It prints
[log] User granted permission: AuthorizationStatus.denied
Also, can you uninstall app, compile and run again and observe what does the
authorizationStatus
returns ?In this case also, it prints the same message.
However if I kill the app, rerun it and allow notifications. Then in subsequent builds, it prints status as authorized.
@darshankawar similar behaviour on example app as well. Although I had to add android:exported to true, add my services.json file and change package name to my app name for it work. Hope it was intended to run it this way.
Thanks for the update. I now noticed that the Android version you are using is 13, so you are most probably hitting https://github.com/firebase/flutterfire/issues/8720. You may try on lesser Android version and see if you still get same behavior or not. If not, then you will need to follow-up in the linked issue.
@darshankawar Yes, on lower android versions, I am directly getting authorised status without any dialog which I believe is expected behaviour in older versions. Thanks for the link to relevant issue. Closing this one.
Bug report
On running the application for first time, the notification permission dialog is not shown and permission status is itself granted to be denied. On killing the app and then starting it, the notification dialog is shown.
Tested on Android Emulator API 33
Expected behavior
Expected to be shown the dialog on first boot.
Sample project
initialized in initstate of materialApp.
Flutter doctor
Flutter dependencies