OneSignal-Website-SDK
OneSignal-Website-SDK copied to clipboard
(Host) isUsingSubscriptionWorkaround() cannot be called until OneSignal.config exists
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
Howdy, It looks like your project is set to private. Please update it so we can help you.
Cheers
Is there any solution to this problem? I am having the same problem.
Any update on this? i followed the documentations and it leads me to this error
@tcetin @HendryVarianto14
Can you try calling the function after you have called the async init
function?
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.
https://github.com/zhex900/push-msg
@nehalist you resolved this error?
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.
I hit this same issue. Problem is that init is async, so you have to either await that or use .then before calling login.
anyone solve this issue?
@hishabee-nazu yes, see my comment above
@hishabee-nazu yes, see my comment above
Thanks, man, It's working. I have just unexpectedly commented out my initial app calling
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 !)