Closed Inzendis closed 8 months ago
Tested on a Vercel hosted version that I had when I tested back then and it worked, got the subscribe message. I dont get it, it doesnt work on localhost or on brave, The hosted one in vercel only worked on chrome.
I just can't seem to be able to test it in localhost.
I think I need to update the importScript to /v16 just noticed that changed to that.
@Inzendis Brave blocks OneSignal by default, tuning off Braves shields should fix the issue you are seeing.
I think I need to update the importScript to /v16 just noticed that changed to that.
Make sure both the .js file used in the <script>
tag on you page AND the service worker importScript
have v16 in the path. Mixing vesions will create issues, so I recommend clearing your site data to ensure it didn't create any issues.
@Inzendis Brave blocks OneSignal by default, tuning off Braves shields should fix the issue you are seeing.
I think I need to update the importScript to /v16 just noticed that changed to that.
Make sure both the .js file used in the
<script>
tag on you page AND the service workerimportScript
have v16 in the path. Mixing vesions will create issues, so I recommend clearing your site data to ensure it didn't create any issues.
Ok fixed it. I made sure to update the SDK importScript and did something else.
If anyone sees this and is using NextJS App Dir 13.5+: Make a component with "use client"
"use client"; import React, { useEffect } from "react"; import OneSignal from "react-onesignal"; async function runOneSignal() { await OneSignal.init({ appId: process.env.NEXT_PUBLIC_APP_ID_KEY as string, allowLocalhostAsSecureOrigin: true, }); OneSignal.Slidedown.promptPush(); } export default function ReactOneSignal() { useEffect(() => { runOneSignal(); }); return <></>; }
Put it in your RootLayout, but inside The body tag as children.
Maybe there is another solution, but that is what worked for me.
Im going to be rendering this if the user is logged in. My auth is with NextAuth, Im going to fetch the session with their method in server component and then check if there is any to active the notifications. Im also going to pass a data tag to the OneSignal.User.
What happened?
In Chrome I can do
And I get all the correct info. In Brave browser I get
Also I got notifications enabled in my PC and in Chrome and I can subscribe there but when I do test notifications it doesn't work.
It used to work a couple of months ago, maybe July of last year when I was testing this before thinking of using it. And now that I need it its a problem.
Maybe because im in a sub directory /home?
What browsers are you seeing the problem on?
Brave
What operating system are you running?
Windows 10
Steps to reproduce?
What did you expect to happen?
Just basic notifications to be sent and received
Relevant log output