Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. App.push = (function(){
  2.  
  3. var id = '[---App ID---]';
  4.  
  5. var notificationOpenedCallback = function(jsonData) {
  6. console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
  7. };
  8.  
  9. var init = function(customid, callback){
  10. id = customid ? customid : id;
  11. console.log('Initializing push');
  12. if(!window.cordova){
  13. return;
  14. }
  15. window.plugins.OneSignal.init(id, {googleProjectNumber: ""}, notificationOpenedCallback);
  16. // Show an alert box if a notification comes in when the user is in your app.
  17. window.plugins.OneSignal.enableInAppAlertNotification(true);
  18. getID(callback);
  19. };
  20.  
  21. var getID = function(callback){
  22. console.log('Get push ids');
  23. window.plugins.OneSignal.getIds(function(ids) {
  24. console.log('getIds: ' + JSON.stringify(ids));
  25. if(callback){
  26. callback();
  27. }
  28. });
  29. };
  30.  
  31. return {
  32. init:init
  33. };
  34.  
  35.  
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement