Ok so I am working the Push notifications for my app. I have registered with Apple and GCM. I have placed my code within the registration and login script. My goal is when a user logins/registers they are agreeing to push notifications as stated in their agreement of the Terms of Service.
However, I keep getting errors. I am new to mobile app development.
Any help would be great.
.controller('LogController', function($scope, LoginService, $ionicPlatform, $cordovaDevice, $cordovaPush, $location) { $scope.login= function(){
// Lets begin the Login
LoginService.login($scope.login.email, $scope.login.password).then(function(data){
if(data['error'] == 1) {
$scope.message = data['error_msg'];
}
$ionicPlatform.ready(function() {
// Now lets register them for the push notifications
var androidConfig = {
"senderID":"63017977738",
};
var iosConfig = {
"badge":"true",
"sound":"true",
"alert":"true",
};
if(device.platform == 'Android') {
$cordovaPush.register(androidConfig).then(function(result) {
console.log(result);
alert(result);
}, function(err) {
alert('error');
});
} else if(device.platform == 'iOS') {
$cordovaPush.register(iosConfig).then(function(result) {
console.log(result);
alert(result);
}, function(err) {
alert('error');
});
// iOS only
$cordovaPush.setBadgeNumber(2).then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
}
});
$location.path('/hotellogin');
});
})