OneSignal / react-onesignal

React OneSignal Module: Make it easy to integrate OneSignal with your React App!
Other
74 stars 23 forks source link

HTTPs not working with Chrome #61

Closed usman0011 closed 2 years ago

usman0011 commented 2 years ago

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
  2. 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

rgomezp commented 2 years ago

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

Cheers