-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcordova.js
37 lines (29 loc) · 1.03 KB
/
cordova.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Pushwoosh = {};
Pushwoosh.initPushwoosh = function(appId) {
var pushNotification = window.plugins.pushNotification;
//set push notification callback before we initialize the plugin
document.addEventListener('push-notification', function(event) {
//get the notification payload
var notification = event.notification;
//clear the app badge
pushNotification.setApplicationIconBadgeNumber(0);
});
//initialize the plugin
pushNotification.onDeviceReady({pw_appid:appId });
//register for pushes
pushNotification.registerDevice(
function(status) {
var deviceToken = status['deviceToken'];
console.warn('registerDevice: ' + deviceToken);
},
function(status) {
console.warn('failed to register : ' + JSON.stringify(status));
alert(JSON.stringify(['failed to register ', status]));
}
);
//reset badges on app start
pushNotification.setApplicationIconBadgeNumber(0);
}
Pushwoosh.createMessage = function(notification) {
throw new Meteor.Error('302', 'Only supported on server');
}