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]: Using function #146

Open
Arkningy opened this issue Jul 23, 2024 · 0 comments
Open

[Bug]: Using function #146

Arkningy opened this issue Jul 23, 2024 · 0 comments

Comments

@Arkningy
Copy link

What happened?

Hello,

So i'm using this version : "react-onesignal": "^3.0.1",

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

Windows 11

Steps to reproduce?

npm install --save react-onesignal
I've added the OneSignalSDKWorker.js file to my public folder and I've verified that I can access it by typing this address : http://localhost:3000/OneSignalSDKWorker.js
Then i tried to use this code :
// Get the subscription ID
  const getSubscriptionId = async () => {
    try {
      const userId = await OneSignal.getUserId();
      //setSubscriptionId(userId);
      console.log('Subscription ID:', userId);
    } catch (error) {
      console.error('Error getting subscription ID:', error);
    }
  };

Or even this : await OneSignal.setSubscription(false);

But everytime that I try to call one of those function I get this error :

HomePage.js:39 Error getting subscription ID: TypeError: react_onesignal__WEBPACK_IMPORTED_MODULE_2__.default.getUserId is not a function
    at getSubscriptionId (HomePage.js:35:1)
    at handleUnsubscribe (HomePage.js:45:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
    at invokeGuardedCallback (react-dom.development.js:4277:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)
    at executeDispatch (react-dom.development.js:9041:1)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:1)
    at processDispatchQueue (react-dom.development.js:9086:1)
    at dispatchEventsForPlugins (react-dom.development.js:9097:1)

What did you expect to happen?

I expected the function to be treated as so but apparently it's not so I'm lost and I don't know how to solve this issue

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