Switch from a timeout strategy to script#onload and script#onerror so
that calls to #init will always resolve. This is important for consumers
of the react-onesignal package who want to call multiple functions
synchronously, for example:
Without this change, those calls will hang indefinitely if adblock
prevents executing the web SDK from the cdn.onesignal.com domain.
An additional flag, isOneSignalScriptFailed is kept around to resolve
OneSignal SDK methods in the event of a CDN load failure. Since
resolutions in the queue are only called on #init, if SDK methods are
called after #init has already failed they will never resolve.
Also includes other minor miscellaneous nits and improvements.
Switch from a timeout strategy to script#onload and script#onerror so that calls to #init will always resolve. This is important for consumers of the react-onesignal package who want to call multiple functions synchronously, for example:
Without this change, those calls will hang indefinitely if adblock prevents executing the web SDK from the cdn.onesignal.com domain.
An additional flag,
isOneSignalScriptFailed
is kept around to resolve OneSignal SDK methods in the event of a CDN load failure. Since resolutions in the queue are only called on#init
, if SDK methods are called after#init
has already failed they will never resolve.Also includes other minor miscellaneous nits and improvements.