Skip to content

Instantly share code, notes, and snippets.

@addityasingh
Last active April 1, 2016 21:07
Show Gist options
  • Save addityasingh/68956e1cb3a1cab9bb3513df64e3907d to your computer and use it in GitHub Desktop.
Save addityasingh/68956e1cb3a1cab9bb3513df64e3907d to your computer and use it in GitHub Desktop.
Setup phonegap-push-plugin for ionic app
$PATH_TO_PROVISIONING_PROFILE = ""
$DEVELOPER_TEAM_ID = ""
xcodebuild PROVISIONING_PROFILE="$PATH_TO_PROVISIONING_PROFILE" CODE_SIGN_IDENTITY="$DEVELOPER_TEAM_ID"
function registerForPush () {
if ($window.PushNotification) {
var push = $window.PushNotification.init({
ios: {
“badge”: false,
“sound”: true,
“alert”: true,
“clearBadge”: true
}
});
push.on(‘registration’, function(deviceToken){
$rootScope.deviceToken = deviceToken.registrationId || ‘’; // Send this devicetoken to your app servers
});
push.on(‘error’, function(data) {
console.log(“Push plugin registration error”+ JSON.stringify(data));
});
push.on(‘notification’, function(data) {
$rootScope.$broadcast(‘push-notification-data’, { data: data.additionalData });
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment