Skip to content

Instantly share code, notes, and snippets.

@dabit3
Created August 22, 2016 23:16
Show Gist options
  • Save dabit3/94d73123a2264c20af03c6abd1b207c8 to your computer and use it in GitHub Desktop.
Save dabit3/94d73123a2264c20af03c6abd1b207c8 to your computer and use it in GitHub Desktop.
services.js updated
// initialize
if (typeof PushNotification === "defined") {
// your code here
$cordovaPushV5.initialize(options).then(function() {
// start listening for new notifications
$cordovaPushV5.onNotification();
// start listening for errors
$cordovaPushV5.onError();
// register to get registrationId
$cordovaPushV5.register().then(function(deviceToken) {
// Success -- send deviceToken to server, and store for future use
console.log("your deviceToken: " + deviceToken);
console.log('url should be showing');
console.log(deviceType);
console.log('the url is: '+ WORDPRESS_PUSH_URL);
console.log(WORDPRESS_PUSH_URL + '/savetoken/?device_token='+ deviceToken +'&device_type='+ deviceType);
console.log(regDetails);
$http.post(regDetails);
console.log('everything worked.');
}, function(error) {
alert("Registration error: " + error);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment