Skip to content

[Question]: How should requestPermission method be used #170

@Kismar

Description

@Kismar

How can we help?

Hi,
I was updating my project from v2 to v3 and I run into an issue with
OneSignal.Notifications.requestPermission()

When and how should be this method be used? When I ran this method the OneSignal looked stuck.
Here is the code that I tried to run:

const init = () ->> {
    OneSignal.init({ appId: AppId });
}
const login = (user: string) => {
 console.log('Requesting permission');
 await OneSignal.Notifications.requestPermission();
 console.log('Permission successfully requested'); //this consol.log will will not be printed
 await OneSignal.login(user);
}

but if I run the same function without await the function run and user is logged into OneSignal and notifications are received.

const login = (user: string) => {
 console.log('Requesting permission');
 OneSignal.Notifications.requestPermission();
 console.log('Permission successfully requested'); // console.log will be printed
 await OneSignal.login(user);
}

Is there an reason why it gets stuck on this awaited method?
Thank you in advance for any response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions