I'm trying to return this .register()
method:
var deferred = $q.defer();
$cordovaPushV5.initialize($constants.PUSH_OPTIONS).then(function () {
$cordovaPushV5.onError();
$cordovaPushV5.onNotification();
return $cordovaPushV5.register();
}).then(function (push_token) {
deferred.resolve(push_token);
});
return deferred.promise;
But it is never resolving with push_token... This seems to be correct according to other questions i've seen, However I can't get it to work properly.. Any help is greatly appreciated. Thanks!.
I don't know about Cordova, but Promise seems fine.
But it can be simplified :
return $cordovaPushV5.initialize($constants.PUSH_OPTIONS)
.then(function () {
$cordovaPushV5.onError();
$cordovaPushV5.onNotification();
return $cordovaPushV5.register();
}, function(error) {
console.log(error);
});