Skip to content

Commit

Permalink
OneSignal library initialization now occurs regardless of whether the…
Browse files Browse the repository at this point in the history
… window.onload event has yet to be fired or has already fired.
  • Loading branch information
Jason Pang committed Oct 21, 2015
1 parent ab22f9a commit 74cc481
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 11 additions & 3 deletions onesignal-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,22 @@ function initOneSignal() {
OneSignal.init(oneSignal_options);
}

window.addEventListener("load", function(event){
function documentInitOneSignal() {
OneSignal.push(initOneSignal);

var oneSignal_elements = document.getElementsByClassName("OneSignal-prompt");
var oneSignalLinkClickHandler = function(event) { OneSignal.push(['registerForPushNotifications', {modalPrompt: true}]); event.preventDefault(); };
for(var i = 0; i < oneSignal_elements.length; i++)
oneSignal_elements[i].addEventListener('click', oneSignalLinkClickHandler, false);
});
}

if (document.readyState === 'complete') {
documentInitOneSignal();
}
else {
window.addEventListener("load", function(event){
documentInitOneSignal();
});
}
</script>

<?php
Expand Down
2 changes: 1 addition & 1 deletion onesignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: OneSignal Push Notifications
* Plugin URI: https://onesignal.com/
* Description:
* Version: 1.1.0
* Version: 1.1.1
* Author: OneSignal
* Author URI: https://onesignal.com
* License: MIT
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://onesignal.com
Tags: chrome, safari, push, push notifications, safari, chrome push, safari push, notifications, web push, notification, notify, mavericks, firefox push, android, android push, android notifications, mobile notifications, mobile, desktop notifications, gcm, push messages, onesignal
Requires at least: 3.8
Tested up to: 4.3.1
Stable tag: 1.1.0
Stable tag: 1.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -45,6 +45,9 @@ Features:
3. Follow the instructions on the new OneSignal Wordpress menu option to get started.

== Changelog ==
= 1.1.1 =
- OneSignal library initialization now occurs regardless of whether the window.onload event has yet to be fired or has already fired.

= 1.1.0 =
- Added Safari Mac OSX support.

Expand Down

0 comments on commit 74cc481

Please sign in to comment.