How settings in Ionic
-
Hello friend , I am interested in your plugin, but would like to try before you buy . Already I installed in on my wordpress and configured , but I can not send the app token for the plugin.
I used this code in function run on ionic:
var androidConfig, iosConfig, register; androidConfig = { "senderID": "XXXXXX" }; iosConfig = { "badge": true, "sound": true, "alert": true }; register = function(os, token) { var baseUrl; baseUrl = 'https://dev.bahia.ba/pnfw'; if (!baseUrl) { return $q.reject(); } return $http({ method: 'POST', url: baseUrl + '/register', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var p, str; str = []; for (p in obj) { str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p])); } return str.join('&'); }, data: { os: os, token: token } }); }; return $ionicPlatform.ready(function() { if (ionic.Platform.isAndroid()) { $cordovaPush.register(androidConfig).then(function(result) { $log.debug('android push notification registration success', result); }, function(err) { $log.error('android push notification registration error', err); }); return $rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) { switch (notification.event) { case 'registered': if (!notification.regid.length) { return; } $log.debug('registration ID', notification.regid); register('Android', notification.regid).success(function() { return $log.info('Push notif Token stored'); }); break; case 'message': $log.debug('Push notif message', notification); if (notification.foreground) { // If your user is using the app // Do something like opening the Post within the app // You have access to // notification.payload.id which is the new Post ID // notification.payload.message which is the new Post Title } else { // If your user has clicked on the notification // Do something like opening the Post within the app // You have access to // notification.payload.id which is the new Post ID // notification.payload.message which is the new Post Title } break; case 'error': $log.debug('Push notif error', notification); break; } }); } else if (ionic.Platform.isIOS()) { $cordovaPush.register(iosConfig).then(function(deviceToken) { register('iOS', deviceToken).success(function() { return $log.info('Push notif Token stored'); }); $log.debug('iOS push notification registration success', deviceToken); }, function(err) { $log.error('iOS push notification registration error', err); }); return $rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) { $log.debug('Push notif message', notification); if (notification.alert) { if (notification.foreground) { // If your user is using the app // Do something like opening the Post within the app // You have access to // notification.id which is the new Post ID // notification.alert which is the new Post Title } else { // If your user has clicked on the notification // Do something like opening the Post within the app // You have access to // notification.id which is the new Post ID // notification.alert which is the new Post Title } } if (notification.badge) { return $cordovaPush.setBadgeNumber(notification.badge).then(function(result) { $log.debug('Push notif badge ok', result); }, function(err) { $log.debug('Push notif badge error', err); }); } }); } }, false);
My base url is https://dev.bahia.ba/pnfw
You can me help?
Thanks…
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How settings in Ionic’ is closed to new replies.