|
1 | 1 | (function(cordova) { |
2 | 2 |
|
3 | | - function OrtcPushPlugin() {} |
| 3 | + function OrtcPushPlugin() {} |
4 | 4 |
|
5 | 5 |
|
6 | | - OrtcPushPlugin.prototype.checkForNotifications = function(success) { |
| 6 | + OrtcPushPlugin.prototype.checkForNotifications = function(success) { |
7 | 7 | cordova.exec(success, success, "OrtcPushPlugin", "checkForNotifications", []); |
8 | | - }; |
9 | | - |
10 | | - OrtcPushPlugin.prototype.removeNotifications = function(success) { |
| 8 | + }; |
| 9 | + |
| 10 | + OrtcPushPlugin.prototype.removeNotifications = function(success) { |
11 | 11 | cordova.exec(success, success, "OrtcPushPlugin", "removeNotifications", []); |
12 | | - }; |
13 | | - |
14 | | - OrtcPushPlugin.prototype.connect = function(config, success) { |
| 12 | + }; |
| 13 | + |
| 14 | + OrtcPushPlugin.prototype.connect = function(config, success) { |
15 | 15 | cordova.exec(success, success, "OrtcPushPlugin", "connect", config ? [config] : []); |
16 | | - }; |
17 | | - |
18 | | - OrtcPushPlugin.prototype.disconnect = function(success) { |
| 16 | + }; |
| 17 | + |
| 18 | + OrtcPushPlugin.prototype.enableHeadsUpNotifications = function(config, success) { |
| 19 | + cordova.exec(success, success, "OrtcPushPlugin", "enableHeadsUpNotifications", []); |
| 20 | + }; |
| 21 | + |
| 22 | + OrtcPushPlugin.prototype.disableHeadsUpNotifications = function(config, success) { |
| 23 | + cordova.exec(success, success, "OrtcPushPlugin", "disableHeadsUpNotifications", []); |
| 24 | + }; |
| 25 | + |
| 26 | + OrtcPushPlugin.prototype.disconnect = function(success) { |
19 | 27 | cordova.exec(success, success, "OrtcPushPlugin", "disconnect", []); |
20 | | - }; |
21 | | - |
22 | | - OrtcPushPlugin.prototype.subscribe = function(config, success) { |
| 28 | + }; |
| 29 | + |
| 30 | + OrtcPushPlugin.prototype.subscribe = function(config, success) { |
23 | 31 | cordova.exec(success, success, "OrtcPushPlugin", "subscribe", config ? [config] : []); |
24 | | - }; |
25 | | - |
26 | | - |
27 | | - OrtcPushPlugin.prototype.unsubscribe = function(config, success) { |
| 32 | + }; |
| 33 | + |
| 34 | + |
| 35 | + OrtcPushPlugin.prototype.unsubscribe = function(config, success) { |
28 | 36 | cordova.exec(success, success, "OrtcPushPlugin", "unsubscribe", config ? [config] : []); |
29 | | - }; |
30 | | - |
31 | | - OrtcPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge, callback) { |
| 37 | + }; |
| 38 | + |
| 39 | + OrtcPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge, callback) { |
32 | 40 | cordova.exec(callback, callback, "OrtcPushPlugin", "setApplicationIconBadgeNumber", [badge]); |
33 | | - }; |
34 | | - |
35 | | - OrtcPushPlugin.prototype.send = function(config) { |
| 41 | + }; |
| 42 | + |
| 43 | + OrtcPushPlugin.prototype.send = function(config) { |
36 | 44 | cordova.exec(null, null, "OrtcPushPlugin", "send", config ? [config] : []); |
37 | | - }; |
38 | | - |
39 | | - // Call this to clear all notifications from the notification center |
40 | | - OrtcPushPlugin.prototype.cancelAllLocalNotifications = function(callback) { |
| 45 | + }; |
| 46 | + |
| 47 | + // Call this to clear all notifications from the notification center |
| 48 | + OrtcPushPlugin.prototype.cancelAllLocalNotifications = function(callback) { |
41 | 49 | cordova.exec(callback, callback, "OrtcPushPlugin", "cancelAllLocalNotifications", []); |
42 | | - }; |
43 | | - |
44 | | - OrtcPushPlugin.prototype.log = function(log) { |
| 50 | + }; |
| 51 | + |
| 52 | + OrtcPushPlugin.prototype.log = function(log) { |
45 | 53 | cordova.exec(null, null, "OrtcPushPlugin", "log", log ? [log] : []); |
46 | | - }; |
47 | | - |
48 | | - OrtcPushPlugin.prototype.receiveRemoteNotification = function(channel, payload) { |
| 54 | + }; |
| 55 | + |
| 56 | + OrtcPushPlugin.prototype.receiveRemoteNotification = function(channel, payload) { |
49 | 57 | var ev = document.createEvent('HTMLEvents'); |
50 | 58 | ev.channel = channel; |
51 | 59 | ev.payload = payload; |
52 | 60 | ev.initEvent('push-notification', true, true, arguments); |
53 | 61 | document.dispatchEvent(ev); |
54 | | - }; |
| 62 | + }; |
55 | 63 |
|
56 | | - OrtcPushPlugin.prototype.onException = function(error){ |
| 64 | + OrtcPushPlugin.prototype.onException = function(error){ |
57 | 65 | var ev = document.createEvent('HTMLEvents'); |
58 | 66 | ev.description = error; |
59 | 67 | ev.initEvent('onException', true, true, arguments); |
60 | 68 | document.dispatchEvent(ev); |
61 | | - }; |
62 | | - |
63 | | - cordova.addConstructor(function() { |
| 69 | + }; |
| 70 | + |
| 71 | + cordova.addConstructor(function() { |
64 | 72 | if(!window.plugins) window.plugins = {}; |
65 | 73 | window.plugins.OrtcPushPlugin = new OrtcPushPlugin(); |
66 | 74 | }); |
67 | | - |
68 | | - })(window.cordova || window.Cordova || window.PhoneGap); |
69 | | - |
70 | | - |
71 | | - // call when device is ready |
72 | | - document.addEventListener("deviceready", function () { |
73 | | - if(window.plugins && window.plugins.OrtcPushPlugin){ |
74 | | - var OrtcPushPlugin = window.plugins.OrtcPushPlugin; |
75 | | - OrtcPushPlugin.checkForNotifications(); |
76 | | - |
77 | | - } |
78 | | - }); |
79 | | - |
80 | | - |
81 | | - // call when app resumes |
82 | | - document.addEventListener("resume", function () { |
83 | | - if(window.plugins && window.plugins.OrtcPushPlugin){ |
84 | | - var OrtcPushPlugin = window.plugins.OrtcPushPlugin; |
85 | | - OrtcPushPlugin.checkForNotifications(); |
86 | | - } |
87 | | - }); |
88 | 75 |
|
| 76 | +})(window.cordova || window.Cordova || window.PhoneGap); |
| 77 | + |
| 78 | + |
| 79 | +// call when device is ready |
| 80 | +document.addEventListener("deviceready", function () { |
| 81 | + if(window.plugins && window.plugins.OrtcPushPlugin){ |
| 82 | + var OrtcPushPlugin = window.plugins.OrtcPushPlugin; |
| 83 | + OrtcPushPlugin.checkForNotifications(); |
89 | 84 |
|
| 85 | + } |
| 86 | + }); |
90 | 87 |
|
91 | 88 |
|
| 89 | +// call when app resumes |
| 90 | +document.addEventListener("resume", function () { |
| 91 | + if(window.plugins && window.plugins.OrtcPushPlugin){ |
| 92 | + var OrtcPushPlugin = window.plugins.OrtcPushPlugin; |
| 93 | + OrtcPushPlugin.checkForNotifications(); |
| 94 | + } |
| 95 | + }); |
92 | 96 |
|
0 commit comments