Used the 'react-onesignal' package inside a React Typescript project created with Vite.
Description
In a Chrome browser, native prompt simply refuses to open on any HTTPs site where the project is deployed, thus not registering the user and not receiving any notifications.
Reproducing Steps
One Signal App
Iintialization in React App
import OneSignal from "react-onesignal";
await OneSignal.init({ appId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" });
const notfEnabled = await OneSignal.isPushNotificationsEnabled();
if (!notfEnabled) {
await OneSignal.showNativePrompt();
if (await OneSignal.isPushNotificationsEnabled()) {
OneSignal.setSubscription(true);
const deviceID = await OneSignal.getUserId();
console.log(deviceID);
if (deviceID) dispatch(AddDevice(deviceID as string));
else console.log("error in user ID", deviceID);
}
}
Project
Used the 'react-onesignal' package inside a React Typescript project created with Vite.
Description
In a Chrome browser, native prompt simply refuses to open on any HTTPs site where the project is deployed, thus not registering the user and not receiving any notifications.
Reproducing Steps
One Signal App
Iintialization in React App
Versions
React One Signal - ^2.0.3 Chrome - 99.0.4844.83 (Official Build) (x86_64) Firefox - 98.0.2 (64-bit) Node - v16.13.2 NPM - 8.1.2