@@ -17,8 +17,12 @@ JPushPlugin.prototype.errorCallback = function (msg) {
1717 console . log ( 'JPush Callback Error: ' + msg )
1818}
1919
20- JPushPlugin . prototype . callNative = function ( name , args , successCallback ) {
21- cordova . exec ( successCallback , this . errorCallback , 'JPushPlugin' , name , args )
20+ JPushPlugin . prototype . callNative = function ( name , args , successCallback , errorCallback ) {
21+ if ( errorCallback ) {
22+ cordova . exec ( successCallback , errorCallback , 'JPushPlugin' , name , args )
23+ } else {
24+ cordova . exec ( successCallback , this . errorCallback , 'JPushPlugin' , name , args )
25+ }
2226}
2327
2428// Common methods
@@ -66,7 +70,7 @@ JPushPlugin.prototype.clearLocalNotifications = function () {
6670 }
6771}
6872
69- JPushPlugin . prototype . setTagsWithAlias = function ( tags , alias ) {
73+ JPushPlugin . prototype . setTagsWithAlias = function ( tags , alias , successCallback , errorCallback ) {
7074 if ( tags == null ) {
7175 this . setAlias ( alias )
7276 return
@@ -77,15 +81,15 @@ JPushPlugin.prototype.setTagsWithAlias = function (tags, alias) {
7781 }
7882 var arrayTagWithAlias = [ tags ]
7983 arrayTagWithAlias . unshift ( alias )
80- this . callNative ( 'setTagsWithAlias' , arrayTagWithAlias , null )
84+ this . callNative ( 'setTagsWithAlias' , arrayTagWithAlias , successCallback , errorCallback )
8185}
8286
83- JPushPlugin . prototype . setTags = function ( tags ) {
84- this . callNative ( 'setTags' , tags , null )
87+ JPushPlugin . prototype . setTags = function ( tags , successCallback , errorCallback ) {
88+ this . callNative ( 'setTags' , tags , successCallback , errorCallback )
8589}
8690
87- JPushPlugin . prototype . setAlias = function ( alias ) {
88- this . callNative ( 'setAlias' , [ alias ] , null )
91+ JPushPlugin . prototype . setAlias = function ( alias , successCallback , errorCallback ) {
92+ this . callNative ( 'setAlias' , [ alias ] , successCallback , errorCallback )
8993}
9094
9195// 判断系统设置中是否对本应用启用通知。
@@ -205,13 +209,13 @@ JPushPlugin.prototype.addNotificationActions = function (actions, categoryId) {
205209
206210// Android methods
207211JPushPlugin . prototype . setBasicPushNotificationBuilder = function ( ) {
208- if ( device . platform == 'Android' ) {
212+ if ( device . platform === 'Android' ) {
209213 this . callNative ( 'setBasicPushNotificationBuilder' , [ ] , null )
210214 }
211215}
212216
213217JPushPlugin . prototype . setCustomPushNotificationBuilder = function ( ) {
214- if ( device . platform == 'Android' ) {
218+ if ( device . platform === 'Android' ) {
215219 this . callNative ( 'setCustomPushNotificationBuilder' , [ ] , null )
216220 }
217221}
@@ -258,14 +262,14 @@ JPushPlugin.prototype.clearNotificationById = function (id) {
258262}
259263
260264JPushPlugin . prototype . setLatestNotificationNum = function ( num ) {
261- if ( device . platform == 'Android' ) {
265+ if ( device . platform === 'Android' ) {
262266 this . callNative ( 'setLatestNotificationNum' , [ num ] , null )
263267 }
264268}
265269
266270JPushPlugin . prototype . addLocalNotification = function ( builderId , content , title ,
267271 notificationID , broadcastTime , extras ) {
268- if ( device . platform == 'Android' ) {
272+ if ( device . platform === 'Android' ) {
269273 this . callNative ( 'addLocalNotification' ,
270274 [ builderId , content , title , notificationID , broadcastTime , extras ] , null )
271275 }
0 commit comments