OneSignal/react-onesignal

HTTPs not working with Chrome

usman0011 opened this issue · 1 comments

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

  1. One Signal App

Screenshot 2022-03-28 at 1 25 39 PM

Screenshot 2022-03-28 at 1 27 26 PM

  1. 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);
      }
    }

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

Howdy,
You need to choose Custom Code, not Typical Site.

Cheers