Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: subscriptionChange not being called #38

Closed
j-oppenhuis opened this issue Jun 17, 2023 · 1 comment
Closed

[Bug]: subscriptionChange not being called #38

j-oppenhuis opened this issue Jun 17, 2023 · 1 comment

Comments

@j-oppenhuis
Copy link

j-oppenhuis commented Jun 17, 2023

What happened?

subscriptionChange is not being triggered. I expect it to be called when permission has been granted and the web worker is loaded. Because of this we can't get the user id. We use this in a PWA, so we run it in Android and iOS, only after the app is closed and opened again we are able to get the user id.

The following issue seem to describe the same:
OneSignal/OneSignal-Android-SDK#749

What browsers are you seeing the problem on?

Chrome (Chromium), Safari

What operating system are you running?

PWA Android (and maybe iOS devices?)

Steps to reproduce?

// First init oneSignal
await this.oneSignal.init({
  appId: '{id}',
  autoResubscribe: true,
  allowLocalhostAsSecureOrigin: true,
  serviceWorkerParam: {
    scope: '/{scope}'
  },
  serviceWorkerPath: '/{path}'
});

// Listen to subscriptionChange
this.oneSignal.on('subscriptionChange', isSubscribed => {
  // This never gets called
  console.log('One signal subscription changed', isSubscribed);
  if (isSubscribed) {
    this.initAfterSubscription();
  }
});

const permission = await this.oneSignal.getNotificationPermission();
if (permission === 'denied') {
  return;
}

if (permission === 'default') {
  await this.oneSignal.showNativePrompt();
}

What did you expect to happen?

I expected to see the console log inside the subscriptionChange listener.

Relevant log output

No response

@jkasten2
Copy link
Member

@j-oppenhuis I believe this issue is fixed with the 2.0.0 release, however if there is still an issue in 2.0.0 please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants