- Posts: 1
- Thank you received: 0
var acieeApp = angular.module('starter', ['ionic', 'starter.services', 'starter.controllers'])
.run(runFunction)
.constant('APP_URL', production ? productionAPIEndpoint : developmentAPIEndpoint)
.constant('APP_CODE', APP_CODE)
.config(configFunction);
[...]
$ionicPlatform.ready(function () {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
// # Push notifications registering
var push = PushNotification.init({
"android": {"senderID": "3170366007"}
});
push.on('registration', function (data) {
// data.registrationId
if(data.registrationId && typeof data.registrationId == 'string') {
GcmService.registerClient(data.registrationId, function(data) {
// # Calling the scheduler function and see how things go.
triggerSchedulerInterval();
}, function(status) {
console.error('Something happened while trying to register the application via GCM !', status, new Date());
});
}
});
push.on('notification', function (data) {
// # So after calling the interval on a regular basis, if the server has some data to be sent,
// # this event will catch said data.
console.warn('RECEIVED NOTIFICATION MOFOOOOO !', data);
});
push.on('error', function (e) {
// e.message
});
});
[...]
(function() {
angular.module('starter.services').factory('GcmService', GcmService);
GcmService.$inject = ['$http', 'APP_URL', 'APP_CODE'];
function GcmService($http, APP_URL, APP_CODE) {
var schedulerUrl = APP_URL + '/get/push/scheduler';
return {
registerClient : function(token, successCallback, errorCallback) {
$http.get(APP_URL + '/put/push/register?token=' + token + '&appcode=' + APP_CODE + '&platform=android')
.success(function (data, status, headers, config) {
console.info('Registered application GCM', data);
successCallback(data);
})
.error(function (data, status, headers, config) {
errorCallback(status);
});
},
triggerScheduler : function(successCallback, errorCallback) {
$http.get(schedulerUrl)
.success(function (data, status, headers, config) {
console.info('Scheduler triggered successfully', data);
successCallback(data);
})
.error(function (data, status, headers, config) {
errorCallback(status);
});
}
}
}
}).call(this);
{
"status":"ok",
"token":"cdcO3HxffCg:APA91bH95os9ndAnYrSeMXwkMcYUzp66820klAx7EFZ4M0lF6A_xqnF_41SrfbiAHFFaCrJW9jLbzUuhUlXiGcv3iXGgttPeoePvpYHEIVBbo9sDBr888Y24IrpwI7NS6BV_CaazZ-_E",
"appcode":"aciee001",
"platform":"android",
"platform_code":1,
"app_id":"2",
"device_id":11,
"ios_alert":0,
"ios_badge":0,
"ios_sound":0
}
To start processing the pending notifications (with status scheduled and running) it is necessary to call a "trigger" function. The Push Module has a scheduler function that must be called on a regular basis (e.g. from a crontab) to trigger the sending of scheduled push notifications.
{status: "ok", batch_size: 10, sent: 1, success: 0, failure: 1}
Please Log in or Create an account to join the conversation.
To start processing the pending notifications (with status scheduled and running) it is necessary to call a "trigger" function. The Push Module has a scheduler function that must be called on a regular basis (e.g. from a crontab) to trigger the sending of scheduled push notifications.
0,10,20,30,40,50 * * * * wget http://www.yoursite.com/endpoint/get/push/scheduler?api_key=123456
*/5 * * * * wget http://www.yoursite.com/endpoint/get/push/scheduler?api_key=123456
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.