I am trying to set up APN reception on an Angular Ionic Framework App with Cordova that has been deployed using Yoman. And so far I am not getting any positive result whatsoever.
What I would like is the ability to display on my app the device token from within Angular so that I can handle it with my api. It could be as simple as a console log on device ready or called on request.
I have tried adding PushNotification.js from https://github.com/mgcrea/cordova-push-notification but despite linking the js file into my index.html page, and in my main controller I have:
angular.element(document).ready(function () {
console.log('Hello World');
var pushNotification = window.plugins.pushNotification;
pushNotification.registerDevice({alert:true, badge:true, sound:true}, function(status) {
console.log('registerDevice:%o', status);
navigator.notification.alert(JSON.stringify(['registerDevice', status]));
});
});
This is what I get in my chrome console log:
Uncaught TypeError: Cannot read property 'addConstructor' of undefined
Hello World
Uncaught TypeError: Cannot read property 'pushNotification' of undefined
I have also installed and linked but dont think it serves any purpose right now:
<script src="bower_components/angular-phonegap-push-notification/push.js"></script>
<script src="bower_components/angular-phonegap-ready/ready.js"></script>
Any help on this would be tremendous because I am swimming blind right now.
Thank you.