|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html> |
3 | | - |
| 3 | + |
4 | 4 | <head> |
5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
6 | 6 | <title>JPush Phonegap Simple Demo</title> |
|
18 | 18 |
|
19 | 19 | initiateUI(); |
20 | 20 | }; |
21 | | - |
| 21 | + |
22 | 22 | var getRegistrationID = function() { |
23 | 23 | window.JPush.getRegistrationID(onGetRegistrationID); |
24 | 24 | }; |
25 | | - |
| 25 | + |
26 | 26 | var onGetRegistrationID = function(data) { |
27 | 27 | try { |
28 | 28 | console.log("JPushPlugin:registrationID is " + data); |
29 | | - |
| 29 | + |
30 | 30 | if (data.length == 0) { |
31 | 31 | var t1 = window.setTimeout(getRegistrationID, 1000); |
32 | 32 | } |
|
36 | 36 | console.log(exception); |
37 | 37 | } |
38 | 38 | }; |
39 | | - |
| 39 | + |
40 | 40 | var onTagsWithAlias = function(event) { |
41 | 41 | try { |
42 | 42 | console.log("onTagsWithAlias"); |
|
48 | 48 | console.log(exception) |
49 | 49 | } |
50 | 50 | }; |
51 | | - |
| 51 | + |
52 | 52 | var onOpenNotification = function(event) { |
53 | 53 | try { |
54 | 54 | var alertContent; |
|
62 | 62 | console.log("JPushPlugin:onOpenNotification" + exception); |
63 | 63 | } |
64 | 64 | }; |
65 | | - |
| 65 | + |
66 | 66 | var onReceiveNotification = function(event) { |
67 | 67 | try { |
68 | 68 | var alertContent; |
|
76 | 76 | console.log(exception) |
77 | 77 | } |
78 | 78 | }; |
79 | | - |
| 79 | + |
80 | 80 | var onReceiveMessage = function(event) { |
81 | 81 | try { |
82 | 82 | var message; |
|
90 | 90 | console.log("JPushPlugin:onReceiveMessage-->" + exception); |
91 | 91 | } |
92 | 92 | }; |
93 | | - |
| 93 | + |
94 | 94 | var initiateUI = function() { |
95 | 95 | try { |
96 | 96 | window.JPush.init(); |
|
110 | 110 | var tag2 = $("#tagText2").val() |
111 | 111 | var tag3 = $("#tagText3").val() |
112 | 112 | var tags = [] |
113 | | - |
| 113 | + |
114 | 114 | if (tag1) { |
115 | 115 | tags.push(tag1) |
116 | 116 | } |
|
123 | 123 |
|
124 | 124 | window.JPush.setTags({ sequence: 1, tags: tags }, |
125 | 125 | function (result) { |
126 | | - $("#tagsResult").html(result.tags) |
| 126 | + $("#tagsResult").html(JSON.stringify(result.tags)) |
127 | 127 | }, function (error) { |
128 | 128 | alert(error.code) |
129 | 129 | }) |
|
135 | 135 | $("#getAllTags").click(function (event) { |
136 | 136 | window.JPush.getAllTags({ sequence: 2 }, |
137 | 137 | function (result) { |
138 | | - $("#tagsResult").html(result.tags) |
| 138 | + $("#tagsResult").html(JSON.stringify(result.tags)) |
139 | 139 | }, function (error) { |
140 | 140 | alert(error.code) |
141 | 141 | }) |
|
179 | 179 | }) |
180 | 180 | }); |
181 | 181 | }; |
182 | | - |
| 182 | + |
183 | 183 | document.addEventListener("deviceready", onDeviceReady, false); |
184 | 184 | document.addEventListener("jpush.openNotification", onOpenNotification, false); |
185 | 185 | document.addEventListener("jpush.receiveNotification", onReceiveNotification, false); |
186 | 186 | document.addEventListener("jpush.receiveMessage", onReceiveMessage, false); |
187 | 187 | </script> |
188 | 188 | </head> |
189 | | - |
| 189 | + |
190 | 190 | <body> |
191 | 191 | <div data-role="page" id="page"> |
192 | 192 | <div data-role="content"> |
@@ -235,7 +235,7 @@ <h3>JPushPlugin Example</h3> |
235 | 235 | <input type="button" id="getAllTags" value="Get all tags" /> |
236 | 236 | <input type="button" id="cleanTags" value="Clean tags" /> |
237 | 237 | </div> |
238 | | - |
| 238 | + |
239 | 239 | <div data-role="fieldcontain"> |
240 | 240 | <input type="button" id="setAlias" value="Set alias" /> |
241 | 241 | <input type="button" id="getAlias" value="Get alias" /> |
|
0 commit comments