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]: Onesignal.logout() error #1202

Open
floodfx opened this issue Oct 10, 2024 · 0 comments
Open

[Bug]: Onesignal.logout() error #1202

floodfx opened this issue Oct 10, 2024 · 0 comments

Comments

@floodfx
Copy link

floodfx commented Oct 10, 2024

What happened?

Calling Onesignal.logout() shows error in console.

Error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getIdentityModel')
    at on.<anonymous> (OneSignalSDK.page.es6.js?v=160203:1:220768)
    at Generator.next (<anonymous>)
    at OneSignalSDK.page.es6.js?v=160203:1:267888
    at new Promise (<anonymous>)
    at o (OneSignalSDK.page.es6.js?v=160203:1:267633)
    at on.logout (OneSignalSDK.page.es6.js?v=160203:1:220711)
    at sn.<anonymous> (OneSignalSDK.page.es6.js?v=160203:1:226285)
    at Generator.next (<anonymous>)
    at OneSignalSDK.page.es6.js?v=160203:1:267888
    at new Promise (<anonymous>)

This shows the following line fails:
const e = sn.coreDirector.getIdentityModel();

I assume sn.coreDirector is undefined. Tracking this through the code a bit, it appears that coreDirector should be created when OneSignal.init(...) is called. In debugging, I added another init call to ensure it was invoked, and when I did I got an error saying init can only be run once, so I've confirmed init is being called before logout.

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

macOS

Steps to reproduce?

Load in <head>

<script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>
<script>
  window.OneSignalDeferred = window.OneSignalDeferred || [];
  OneSignalDeferred.push(async function(OneSignal) {
    await OneSignal.init({
      appId: "MY_APP_ID",
    });
  });
</script>

In another section on page:

<script>
  OneSignalDeferred.push(async function(OneSignal) {
    await OneSignal.logout();
  });
</script>


### What did you expect to happen?

No errors and a successful "logout" call.

### Relevant log output

_No response_
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

1 participant