-
-
Save anonymous/14bec1222151de189c55 to your computer and use it in GitHub Desktop.
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
.controller('DashCtrl', function($rootScope, $scope, $ionicPlatform, $rootScope, $cordovaPush, $ionicUser, $ionicPush, $ionicLoading) { | |
$ionicPlatform.ready(function(){ | |
Parse.initialize("sometopsecretstringhere", "anothertopsecretstringhere"); | |
$ionicUser.identify({ | |
user_id: $ionicUser.generateGUID(), | |
// OR, user the device's UUID | |
//user_id: device.uuid | |
}).then(function(){ | |
//success | |
$ionicPush.register({ | |
canShowAlert: true, //Should new pushes show an alert on your screen? | |
canSetBadge: true, //Should new pushes be allowed to update app icon badges? | |
canPlaySound: true, //Should notifications be allowed to play a sound? | |
canRunActionsOnWake: true, // Whether to run auto actions outside the app, | |
onNotification: function(notification) { | |
alert("Notification has arrived!\n"+JSON.stringify(notification)) | |
} | |
}).then(function(){ | |
$rootScope.$on('$cordovaPush:tokenReceived', function(event, data) { | |
alert('Got token '+ data.token +' Platform: '+ data.platform); | |
// Do something with the token, I am saving it to Parse.com class. | |
var newFriend = Parse.Object.extend('userListTutorial'); | |
alert("Parse extended"); | |
var friend = new newFriend(); | |
alert("friend created, now saving"); | |
friend.save({regid: data.token}).then(function(object){ | |
alert("Saved to Parse!"); | |
},function(obj, err){ | |
alert("err"); | |
}); | |
}); | |
}, function(err){ | |
alert("error"); | |
}); | |
}, function(error){ | |
//error | |
}); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment