var app = angular.module(‘app’, [‘ionic’,‘ngCordova’, ‘ionic.cloud’])
.config(function($stateProvider, $urlRouterProvider, $ionicCloudProvider) {
“use strict”;
document.addEventListener(“deviceready”, function () {
$ionicCloudProvider.init({
debug: true,
dev_push : false,
core: {
“app_id”: “appid”
},
push: {
sender_id: “appid”,
pluginConfig: {
ios: {
badge: true,
sound: true
},
android: {
iconColor: “#343434”
}
}
}
});
});
/* Set up the states for the application’s different sections. */
$stateProvider
.state(‘login’, {name: ‘login’, url: ‘/login’, templateUrl: ‘views/content/login.html’, controller: ‘MainCtrl’})
.state(‘cadastro’, {name: ‘register’, url: ‘/register’, templateUrl: ‘views/content/register.html’, controller: ‘MainCtrl’})
.state(‘recover’, {name: ‘recover’, url: ‘/recover’, templateUrl: ‘views/content/recover.html’, controller: ‘MainCtrl’})
.state(‘home’, {name: ‘home’, url: ‘/home’, templateUrl: ‘views/content/home.html’, controller: ‘MainCtrl’})
;
}).controller(‘MainCtrl’, function($scope,$state, $ionicPush) {
$ionicPush.register({
canShowAlert: true,
canSetBadge: true,
canPlaySound: true,
canRunActionsOnWake: true,
}).then(function(t) {
console.log( $ionicPush.saveToken(t) );
}).then(function(t) {
console.log(‘Token saved:’, t.token);
});
$scope.$on(‘cloud:push:notification’, function(event, data) {
var msg = data.message;
alert(msg);
});
$scope.toggleChange = function(event){
var target = event.target;
if(target.checked){
target.value = true;
}else{
target.value = false;
}
};
}).run(function($ionicPlatform, $cordovaDevice,$state) {
window.STATE = $state;
$ionicPlatform.ready(function() {
document.addEventListener(“deviceready”, function () {
var device = $cordovaDevice.getDevice(),
cordova = $cordovaDevice.getCordova(),
model = $cordovaDevice.getModel(),
platform = $cordovaDevice.getPlatform(),
uuid = $cordovaDevice.getUUID(),
version = $cordovaDevice.getVersion();
window.SOCKET = io.connect(CONFIG.server);
SOCKET.on('connect', function(){
STATE.go('login');
LOADER.close();
SOCKET.on('register', function(json){
var dados = JSON.parse(json);
console.log(json);
LOADER.close();
POPUP.show('alert',dados.msg.title,dados.msg.call,'login');
});
// socket.on('popup', function(dados){
// LOADER.close();
// var json = JSON.parse(dados);
// POPUP.show(json.type, json.msg, json.click, json.url);
// });
});
}, false);
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.disableScroll(true)
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
}).directive(‘container’, function ($window) {
return function (scope, element) {
scope.getWindowDimensions = function () {
return { ‘h’: window.innerHeight + keyboardHeight, ‘w’: window.innerWidth };
};
scope.$watch(scope.getWindowDimensions, function (newValue, oldValue) {
loop(element,function(node){
node.style.cssText = ‘height:’ + newValue.h + ‘px;width:’ + newValue.w + ‘px;’;
});
}, true);
}
}).controller(‘form_login’, function($scope) {
FORM.login($scope);
}).controller(‘form_cadastro’, function($scope) {
FORM.register($scope);
}).controller(‘form_recover’, function($scope) {
FORM.register($scope);
});
var keyboardHeight = 0;
window.addEventListener(‘native.keyboardshow’, keyboardShowHandler);
function keyboardShowHandler(e){
keyboardHeight = e.keyboardHeight;
}
window.addEventListener(‘native.keyboardhide’, keyboardHideHandler);
function keyboardHideHandler(e){
keyboardHeight = 0;
}
I am trying to register and this me returning this error in the console