|
1 | 1 | (function(cordova) { |
2 | 2 |
|
3 | 3 | function OrtcPushPlugin() {} |
4 | | - |
5 | | - |
6 | | - OrtcPushPlugin.prototype.checkForNotifications = function(success) { |
7 | | - cordova.exec(success, success, "OrtcPushPlugin", "checkForNotifications", []); |
| 4 | + |
| 5 | + OrtcPushPlugin.prototype.checkForNotifications = function() { |
| 6 | + var promise = new Promise(function(resolve, reject) { |
| 7 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "checkForNotifications", []); |
| 8 | + }); |
| 9 | + return promise; |
8 | 10 | }; |
9 | 11 |
|
10 | | - OrtcPushPlugin.prototype.removeNotifications = function(success) { |
11 | | - cordova.exec(success, success, "OrtcPushPlugin", "removeNotifications", []); |
| 12 | + OrtcPushPlugin.prototype.removeNotifications = function() { |
| 13 | + var promise = new Promise(function(resolve, reject) { |
| 14 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "removeNotifications", []); |
| 15 | + }); |
| 16 | + return promise; |
12 | 17 | }; |
13 | 18 |
|
14 | | - OrtcPushPlugin.prototype.connect = function(config, success) { |
15 | | - cordova.exec(success, success, "OrtcPushPlugin", "connect", config ? [config] : []); |
| 19 | + OrtcPushPlugin.prototype.connect = function(config) { |
| 20 | + var promise = new Promise(function(resolve, reject) { |
| 21 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "connect", config ? [config] : []); |
| 22 | + }); |
| 23 | + return promise; |
16 | 24 | }; |
17 | 25 |
|
18 | | - OrtcPushPlugin.prototype.getIsConnected = function(success) { |
19 | | - cordova.exec(success, success, "OrtcPushPlugin", "getIsConnected", []); |
| 26 | + OrtcPushPlugin.prototype.getIsConnected = function() { |
| 27 | + var promise = new Promise(function(resolve, reject) { |
| 28 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "getIsConnected", []); |
| 29 | + }); |
| 30 | + return promise; |
20 | 31 | }; |
21 | 32 |
|
22 | | - OrtcPushPlugin.prototype.enableHeadsUpNotifications = function(config, success) { |
23 | | - cordova.exec(success, success, "OrtcPushPlugin", "enableHeadsUpNotifications", []); |
| 33 | + OrtcPushPlugin.prototype.enableHeadsUpNotifications = function() { |
| 34 | + var promise = new Promise(function(resolve, reject) { |
| 35 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "enableHeadsUpNotifications", []); |
| 36 | + }); |
| 37 | + return promise; |
24 | 38 | }; |
25 | 39 |
|
26 | | - OrtcPushPlugin.prototype.disableHeadsUpNotifications = function(config, success) { |
27 | | - cordova.exec(success, success, "OrtcPushPlugin", "disableHeadsUpNotifications", []); |
| 40 | + OrtcPushPlugin.prototype.disableHeadsUpNotifications = function() { |
| 41 | + var promise = new Promise(function(resolve, reject) { |
| 42 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "disableHeadsUpNotifications", []); |
| 43 | + }); |
| 44 | + return promise; |
28 | 45 | }; |
29 | 46 |
|
30 | | - OrtcPushPlugin.prototype.disconnect = function(success) { |
31 | | - cordova.exec(success, success, "OrtcPushPlugin", "disconnect", []); |
| 47 | + OrtcPushPlugin.prototype.disconnect = function() { |
| 48 | + var promise = new Promise(function(resolve, reject) { |
| 49 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "disconnect", []); |
| 50 | + }); |
| 51 | + return promise; |
32 | 52 | }; |
33 | 53 |
|
34 | | - OrtcPushPlugin.prototype.subscribe = function(config, success) { |
35 | | - cordova.exec(success, success, "OrtcPushPlugin", "subscribe", config ? [config] : []); |
| 54 | + OrtcPushPlugin.prototype.subscribe = function(config) { |
| 55 | + var promise = new Promise(function(resolve, reject) { |
| 56 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "subscribe", config ? [config] : []); |
| 57 | + }); |
| 58 | + return promise; |
36 | 59 | }; |
37 | 60 |
|
38 | 61 |
|
39 | | - OrtcPushPlugin.prototype.unsubscribe = function(config, success) { |
40 | | - cordova.exec(success, success, "OrtcPushPlugin", "unsubscribe", config ? [config] : []); |
| 62 | + OrtcPushPlugin.prototype.unsubscribe = function(config) { |
| 63 | + var promise = new Promise(function(resolve, reject) { |
| 64 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "unsubscribe", config ? [config] : []); |
| 65 | + }); |
| 66 | + return promise; |
41 | 67 | }; |
42 | 68 |
|
43 | | - OrtcPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge, callback) { |
44 | | - cordova.exec(callback, callback, "OrtcPushPlugin", "setApplicationIconBadgeNumber", [badge]); |
| 69 | + OrtcPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge) { |
| 70 | + var promise = new Promise(function(resolve, reject) { |
| 71 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "setApplicationIconBadgeNumber", [badge]); |
| 72 | + }); |
| 73 | + return promise; |
45 | 74 | }; |
46 | 75 |
|
47 | 76 | OrtcPushPlugin.prototype.send = function(config) { |
48 | | - cordova.exec(null, null, "OrtcPushPlugin", "send", config ? [config] : []); |
| 77 | + cordova.exec(null, null, "OrtcPushPlugin", "send", config ? [config] : []); |
49 | 78 | }; |
50 | 79 |
|
51 | 80 | // Call this to clear all notifications from the notification center |
52 | | - OrtcPushPlugin.prototype.cancelAllLocalNotifications = function(callback) { |
53 | | - cordova.exec(callback, callback, "OrtcPushPlugin", "cancelAllLocalNotifications", []); |
| 81 | + OrtcPushPlugin.prototype.cancelAllLocalNotifications = function() { |
| 82 | + var promise = new Promise(function(resolve, reject) { |
| 83 | + cordova.exec(function(){resolve();}, function(){reject();}, "OrtcPushPlugin", "cancelAllLocalNotifications", []); |
| 84 | + }); |
| 85 | + return promise; |
54 | 86 | }; |
55 | 87 |
|
56 | 88 | OrtcPushPlugin.prototype.log = function(log) { |
57 | | - cordova.exec(null, null, "OrtcPushPlugin", "log", log ? [log] : []); |
| 89 | + cordova.exec(null, null, "OrtcPushPlugin", "log", log ? [log] : []); |
58 | 90 | }; |
59 | 91 |
|
60 | 92 | OrtcPushPlugin.prototype.receiveRemoteNotification = function(channel, payload) { |
@@ -98,3 +130,4 @@ document.addEventListener("resume", function () { |
98 | 130 | } |
99 | 131 | }); |
100 | 132 |
|
| 133 | + |
0 commit comments