Unable to suscribe a user when javascript is asynchronously loaded

web

#1

Hi,

For our java webapp, we don’t put javascript directly inside our jsp/html page but rather in a separated .js file which is loaded asynchronously. Unfortunately, it doesn’t seem to work with the WonderPush SDK as this code is doing nothing (after WonderPush.init(...) )

    WonderPush.ready(function(WonderPushSDK){
          WonderPushSDK.setNotificationEnabled(true);
   }

Because the provided copy/paste script (and the javascript files it’s loading) for web integration are minified, it’s quit hard to understand what everything is doing.

Is it possible to only use the javascript file or does the copy/paste web integration script and wonderpush-loader.min.js are doing some modifications in order to be able to use the WonderPushSDK?

I hope my issue is understandable,
Thanks in advance,


#2

Hi Victor,

I cannot reproduce the issue you’re reporting.
If simulated the inclusion of the loading part of the code (the first few compact lines adding wonderpush-loader.js to the page asynchronously) and then the initialization of the SDK, using setTimeout().
You can do the same by copy/pasting the desired lines in the console at the desired pace.

The script that you should copy/paste to your website does a preliminary check before integration the complete SDK, ensure that the SDK is loaded asynchronously, and predefined WonderPush with the init() and ready() methods behorehand in a manner that the SDK can pick-up later transparently.
Skipping that last part would either cause syntax errors or force you to synchronously load the SDK, reducing the page load speed.

Best.


#3

Hi,

Sorry I couldn’t find the way to mark my issue as “Solved”. It was related to my local configuration of Firefox, I reset it and it works fine now - the issue appears when using self signed certificate and is not linked to the WonderPushSDK.

Thanks anyway for the reply and explanations about the “copy/paste” code purpose.

Best regards,