Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ app.controller('AppCtrl', function($scope, $cordovaPush, $cordovaDialogs, $cordo

// call to register automatically upon device ready
ionPlatform.ready.then(function (device) {
$scope.register();
if (window.localStorage['regid'] !== "true") {
$scope.register();
console.log("regid is not true so registering the device for push notification");
} else {
console.log("regid is true so need for registering");
}
});


Expand Down Expand Up @@ -126,9 +131,12 @@ app.controller('AppCtrl', function($scope, $cordovaPush, $cordovaDialogs, $cordo
$http.post('http://192.168.1.16:8000/subscribe', JSON.stringify(user))
.success(function (data, status) {
console.log("Token stored, device is successfully subscribed to receive push notifications.");

window.localStorage['regid'] = true;
})
.error(function (data, status) {
console.log("Error storing device token." + data + " " + status)
$cordovaToast.showLongBottom('The app is unable to register for push notification, try again later by repopening the app');
}
);
}
Expand Down