Created
February 11, 2016 15:31
-
-
Save mulhoon/61a9a7c7cf6dae5aef26 to your computer and use it in GitHub Desktop.
JS for One Signal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.push = (function(){ | |
var id = '[---App ID---]'; | |
var notificationOpenedCallback = function(jsonData) { | |
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData)); | |
}; | |
var init = function(customid, callback){ | |
id = customid ? customid : id; | |
console.log('Initializing push'); | |
if(!window.cordova){ | |
return; | |
} | |
window.plugins.OneSignal.init(id, {googleProjectNumber: ""}, notificationOpenedCallback); | |
// Show an alert box if a notification comes in when the user is in your app. | |
window.plugins.OneSignal.enableInAppAlertNotification(true); | |
getID(callback); | |
}; | |
var getID = function(callback){ | |
console.log('Get push ids'); | |
window.plugins.OneSignal.getIds(function(ids) { | |
console.log('getIds: ' + JSON.stringify(ids)); | |
if(callback){ | |
callback(); | |
} | |
}); | |
}; | |
return { | |
init:init | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment