Я пытаюсь реализовать концепцию push-уведомлений в своем приложении. После успешной установки плагина, push.on(registration)
метод не вызываяКак реализовать push-уведомления в платформе Cordova?
Моя структура Проект projectname/platforms/android/assets/www
В www
папке содержатся все html,js,css
файлы
notification.js
файл, я позвонил в homepage.html
У меня есть написал код в notification.js is:
document.addEventListener('deviceready', pushNotification, false);
function PushNotification(){
var push = PushNotification.init({ "android": {"senderID": "GCMProjectId(123456789)"},"ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {} });
push.on('registration', function(data) {
alert("registration id is:"+data.registrationId);
var id = localStorage.getItem("userId");
var notifyInput = {
"token":data.registrationId,
"type":"android",
"uid":id
}
});
push.on('notification', function(data) {
alert(data.message);
});
push.on('error', function(e) {
// e.message
alert("error function calling on push notifications");
});
}
Здесь push.on(registration) and push.on(notification)
метод не называет, пожалуйста, дайте нам знать возможные способы получения уведомления для конкретного устройства