Skip to content

[Bug]: OneSignal.Notifications.requestPermission(true) on Android never resolves #1842

Description

@SamYu

What happened?

When calling OneSignal.Notifications.requestPermission(true); on Android, the promise is never resolved and no Android system notification prompt is shown. This makes it so users are unable to get notifications on Android without permission.

const permission = await OneSignal.Notifications.getPermissionAsync();

if (!permission) {
  const result = await OneSignal.Notifications.requestPermission(true);

  console.log("notification permission result", result); // This is never logged

  if (result) {
    await OneSignal.User.pushSubscription.optIn();
    await updateNotificationPermissions({
      variables: {
        input: {
          push: true,
          email: null,
        },
      },
    });
  }

Steps to reproduce?

1. Install `react-native-onesignal` on Expo
2. Call await OneSignal.Notifications.requestPermission(true);
3. Check if code executes after

What did you expect to happen?

It should open the Android system notification permission prompt.

React Native OneSignal SDK version

5.2.13

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