Onesignal Web Push

0

I'm trying to use Onesginal Web but it does not work, the icon below appears but does nothing.

It's all set up on the "onesignal" site

Onesignal is making a call, I believe that I should be in trouble. This is passing in the undefined url.

link

'                       Onesignal Push Notification         

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">

    <link rel="manifest" href="manifest.json">

    <!-- <script src="https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js"async="" ></script> -->


    <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js"async=""></script>
    <script>
      var OneSignal = window.OneSignal || [];
      OneSignal.push(function() {
        OneSignal.init({
          appId: "XXXXX-XXXXX-XXXX-XXXX",
          autoRegister: false,
          allowLocalhostAsSecureOrigin: true,
          notifyButton: {
            enable: true,
          },
        });
      });
    </script>

   

'

    
asked by anonymous 19.04.2018 / 04:12

1 answer

0

I have decided as follows. I created in the onesignal site the "Typical Site" push web and the subscribe feature will only work if your url is "https".

Note: must be added to url that onesignal should point to "Site url"

If you want to get the userId generated by onesignal, follow the function:

function getUserId() {
    var OneSignal = window['OneSignal'] || [];
    OneSignal.push(function() {
      /* These examples are all valid */
      OneSignal.getUserId(function(userId) {
        console.log("OneSignal User ID:", userId);
      });

      OneSignal.getUserId().then(function(userId) {
        console.log("OneSignal User ID:", userId);
      });
    });
}
    
19.04.2018 / 16:12