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

(Host) isUsingSubscriptionWorkaround() cannot be called until OneSignal.config exists #886

Open
zhex900 opened this issue Jun 10, 2022 · 12 comments

Comments

@zhex900
Copy link

zhex900 commented Jun 10, 2022

Description:

I am tried to follow this guide to setup website push notification example.

On load I get this error

Uncaught (in promise) Error: (Host) isUsingSubscriptionWorkaround() cannot be called until OneSignal.config exists.

Steps to Reproduce Issue:

https://github.com/zhex900/push-msg

appId is correct. Try to run it.

yarn

yarn dev

@rgomezp
Copy link
Contributor

rgomezp commented Aug 12, 2022

Howdy,
It looks like your project is set to private. Please update it so we can help you.

Cheers

@tcetin
Copy link

tcetin commented Dec 16, 2022

Is there any solution to this problem? I am having the same problem.

@HendryVarianto14
Copy link

Any update on this? i followed the documentations and it leads me to this error

@rgomezp
Copy link
Contributor

rgomezp commented Jan 9, 2023

@tcetin @HendryVarianto14
Can you try calling the function after you have called the async init function?

@nehalist
Copy link

nehalist commented Feb 4, 2023

Same error.

Next.js 12
Custom _document.ts with

import { Head, Html, Main, NextScript } from "next/document";

export default function Document() {
  return (
    <Html>
      <Head>
        <script async src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  );
}

Added init to per-page layout (https://nextjs.org/docs/basic-features/layouts#per-page-layouts):

useEffect(() => {
    window.OneSignal = window.OneSignal || [];
    window.OneSignal.push(["init", {
      appId: "...",
      safari_web_id: "...",
      notifyButton: {
        enable: true,
      },
      allowLocalhostAsSecureOrigin: true,
    }]);

    return () => {
      window.OneSignal = undefined;
    };
  }, []);

Error:

OneSignalUtils.js:34 Uncaught (in promise) Error: (Host) isUsingSubscriptionWorkaround() cannot be called until OneSignal.config exists.

@albertot-dev
Copy link

https://github.com/zhex900/push-msg

@nehalist you resolved this error?

@nehalist
Copy link

nehalist commented Apr 14, 2023

https://github.com/zhex900/push-msg

@nehalist you resolved this error?

"Solved" isn't probably the right word, but adding OneSignalSDKUpdateWorker.js and OneSignalSDKWorker.js into my public directory solved some issues. HMR is still very bugged, which is probably the reason why I'll ultimately go with a different solution or wait until OneSignal releases a better SDK.

@bmulholland
Copy link

I hit this same issue. Problem is that init is async, so you have to either await that or use .then before calling login.

@hishabee-nazu
Copy link

anyone solve this issue?

@bmulholland
Copy link

@hishabee-nazu yes, see my comment above

@hishabee-nazu
Copy link

@hishabee-nazu yes, see my comment above

Thanks, man, It's working. I have just unexpectedly commented out my initial app calling

@SviatoslavMyhal
Copy link

I hit this same issue. Problem is that init is async, so you have to either await that or use .then before calling login.

tnx, man !)

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

No branches or pull requests

9 participants