Skip to content

[Bug]: OneSignal.Notifications.canRequest() always returns true on Android regardless of whether attempting to request notification permission will show a prompt or not #1146

@Daeon97

Description

@Daeon97

What happened?

According to the canRequest API docs

Whether attempting to request notification permission will show a prompt. Returns true if the device has not been prompted for push notification permission already

Also your own docs states this about the getCanRequestPermission API

returns whether the system will show a permission prompt

However in version 5.5.4 of the Flutter SDK, the latest version as at the time of posting this, this is not the behaviour of the canRequest API. canRequest always returns true regardless of whether the system will show notification permission prompt or not

Steps to reproduce?

1. On fresh open of the app, calling `canRequest` API returns true, as it should
2. Use `requestPermission` to ask Notification permission for the first time
3. Deny the system permission prompt shown the first time
4. Calling `canRequest` API after denying first prompt returns true, as it should
5. Use `requestPermission` to ask Notification permission for the second time
6. Deny the system permission prompt shown the second time
7. Calling `canRequest` API after denying the second prompt returns true again which it should not. It should return false because permission prompt cannot show again
8. Calling `canRequest` API subsequently returns true. `canRequest` API never returns false

What did you expect to happen?

Calling canRequest API after denying the second prompt returns true again which it should not. It should return false because permission prompt cannot show again

OneSignal Flutter SDK version

5.5.4

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions