OneSignal/react-onesignal

[Bug]: Using function

Opened this issue · 0 comments

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