@@ -33,6 +33,7 @@ public static void registerWith(Registrar registrar) {
3333
3434 }
3535
36+ private static String TAG = "| JPUSH | Android | " ;
3637 public static JPushPlugin instance ;
3738 static List <Map <String , Object >> openNotificationCache = new ArrayList <>();
3839
@@ -60,6 +61,7 @@ private JPushPlugin(Registrar registrar, MethodChannel channel) {
6061
6162 @ Override
6263 public void onMethodCall (MethodCall call , Result result ) {
64+ Log .i (TAG ,call .method );
6365 if (call .method .equals ("getPlatformVersion" )) {
6466 result .success ("Android " + android .os .Build .VERSION .RELEASE );
6567 } else if (call .method .equals ("setup" )) {
@@ -90,12 +92,17 @@ public void onMethodCall(MethodCall call, Result result) {
9092 getRegistrationID (call , result );
9193 } else if (call .method .equals ("sendLocalNotification" )) {
9294 sendLocalNotification (call , result );
93- } else {
95+ } else if (call .method .equals ("setBadge" )) {
96+ setBadge (call , result );
97+ }
98+ else {
9499 result .notImplemented ();
95100 }
96101 }
97102
98103 public void setup (MethodCall call , Result result ) {
104+ Log .d (TAG ,"setup :" + call .arguments );
105+
99106 HashMap <String , Object > map = call .arguments ();
100107 boolean debug = (boolean )map .get ("debug" );
101108 JPushInterface .setDebugMode (debug );
@@ -112,6 +119,8 @@ public void setup(MethodCall call, Result result) {
112119 }
113120
114121 public void scheduleCache () {
122+ Log .d (TAG ,"scheduleCache:" );
123+
115124 if (dartIsReady ) {
116125 // try to shedule notifcation cache
117126 for (Map <String , Object > notification : JPushPlugin .openNotificationCache ) {
@@ -131,6 +140,8 @@ public void scheduleCache() {
131140 }
132141
133142 public void setTags (MethodCall call , Result result ) {
143+ Log .d (TAG ,"setTags:" );
144+
134145 List <String >tagList = call .arguments ();
135146 Set <String > tags = new HashSet <>(tagList );
136147 sequence += 1 ;
@@ -139,12 +150,16 @@ public void setTags(MethodCall call, Result result) {
139150 }
140151
141152 public void cleanTags (MethodCall call , Result result ) {
153+ Log .d (TAG ,"cleanTags:" );
154+
142155 sequence += 1 ;
143156 callbackMap .put (sequence , result );
144157 JPushInterface .cleanTags (registrar .context (), sequence );
145158 }
146159
147160 public void addTags (MethodCall call , Result result ) {
161+ Log .d (TAG ,"addTags: " + call .arguments );
162+
148163 List <String >tagList = call .arguments ();
149164 Set <String > tags = new HashSet <>(tagList );
150165 sequence += 1 ;
@@ -153,6 +168,8 @@ public void addTags(MethodCall call, Result result) {
153168 }
154169
155170 public void deleteTags (MethodCall call , Result result ) {
171+ Log .d (TAG ,"deleteTags: " + call .arguments );
172+
156173 List <String >tagList = call .arguments ();
157174 Set <String > tags = new HashSet <>(tagList );
158175 sequence += 1 ;
@@ -161,42 +178,57 @@ public void deleteTags(MethodCall call, Result result) {
161178 }
162179
163180 public void getAllTags (MethodCall call , Result result ) {
181+ Log .d (TAG ,"getAllTags: " );
182+
164183 sequence += 1 ;
165184 callbackMap .put (sequence , result );
166185 JPushInterface .getAllTags (registrar .context (), sequence );
167186 }
168187
169188 public void setAlias (MethodCall call , Result result ) {
189+ Log .d (TAG ,"setAlias: " + call .arguments );
190+
170191 String alias = call .arguments ();
171192 sequence += 1 ;
172193 callbackMap .put (sequence , result );
173194 JPushInterface .setAlias (registrar .context (), sequence , alias );
174195 }
175196
176197 public void deleteAlias (MethodCall call , Result result ) {
198+ Log .d (TAG ,"deleteAlias:" );
199+
177200 String alias = call .arguments ();
178201 sequence += 1 ;
179202 callbackMap .put (sequence , result );
180203 JPushInterface .deleteAlias (registrar .context (), sequence );
181204 }
182205
183206 public void stopPush (MethodCall call , Result result ) {
207+ Log .d (TAG ,"stopPush:" );
208+
184209 JPushInterface .stopPush (registrar .context ());
185210 }
186211
187212 public void resumePush (MethodCall call , Result result ) {
213+ Log .d (TAG ,"resumePush:" );
214+
188215 JPushInterface .resumePush (registrar .context ());
189216 }
190217
191218 public void clearAllNotifications (MethodCall call , Result result ) {
219+ Log .d (TAG ,"clearAllNotifications: " );
220+
192221 JPushInterface .clearAllNotifications (registrar .context ());
193222 }
194223
195224 public void getLaunchAppNotification (MethodCall call , Result result ) {
225+ Log .d (TAG ,"" );
226+
196227
197228 }
198229
199230 public void getRegistrationID (MethodCall call , Result result ) {
231+ Log .d (TAG ,"getRegistrationID: " );
200232
201233 String rid = JPushInterface .getRegistrationID (registrar .context ());
202234 if (rid == null || rid .isEmpty ()) {
@@ -208,6 +240,8 @@ public void getRegistrationID(MethodCall call, Result result) {
208240
209241
210242 public void sendLocalNotification (MethodCall call , Result result ) {
243+ Log .d (TAG ,"sendLocalNotification: " + call .arguments );
244+
211245 try {
212246 HashMap <String , Object > map = call .arguments ();
213247
@@ -232,6 +266,17 @@ public void sendLocalNotification(MethodCall call, Result result) {
232266 }
233267 }
234268
269+ public void setBadge (MethodCall call , Result result ) {
270+ Log .d (TAG ,"setBadge: " + call .arguments );
271+
272+ HashMap <String , Object > map = call .arguments ();
273+ Object numObject = map .get ("badge" );
274+ if (numObject != null ) {
275+ int num = (int )numObject ;
276+ JPushInterface .setBadgeNumber (registrar .context (),num );
277+ result .success (true );
278+ }
279+ }
235280
236281 /**
237282 * 接收自定义消息,通知,通知点击事件等事件的广播
@@ -248,6 +293,7 @@ public JPushReceiver() {
248293 @ Override
249294 public void onReceive (Context context , Intent intent ) {
250295 String action = intent .getAction ();
296+
251297 if (action .equals (JPushInterface .ACTION_REGISTRATION_ID )) {
252298 String rId = intent .getStringExtra (JPushInterface .EXTRA_REGISTRATION_ID );
253299 Log .d ("JPushPlugin" ,"on get registration" );
@@ -264,12 +310,16 @@ public void onReceive(Context context, Intent intent) {
264310 }
265311
266312 private void handlingMessageReceive (Intent intent ) {
313+ Log .d (TAG ,"handlingMessageReceive " + intent .getAction ());
314+
267315 String msg = intent .getStringExtra (JPushInterface .EXTRA_MESSAGE );
268316 Map <String , Object > extras = getNotificationExtras (intent );
269317 JPushPlugin .transmitMessageReceive (msg , extras );
270318 }
271319
272320 private void handlingNotificationOpen (Context context , Intent intent ) {
321+ Log .d (TAG ,"handlingNotificationOpen " + intent .getAction ());
322+
273323 String title = intent .getStringExtra (JPushInterface .EXTRA_NOTIFICATION_TITLE );
274324 String alert = intent .getStringExtra (JPushInterface .EXTRA_ALERT );
275325 Map <String , Object > extras = getNotificationExtras (intent );
@@ -284,13 +334,17 @@ private void handlingNotificationOpen(Context context, Intent intent) {
284334 }
285335
286336 private void handlingNotificationReceive (Context context , Intent intent ) {
337+ Log .d (TAG ,"handlingNotificationReceive " + intent .getAction ());
338+
287339 String title = intent .getStringExtra (JPushInterface .EXTRA_NOTIFICATION_TITLE );
288340 String alert = intent .getStringExtra (JPushInterface .EXTRA_ALERT );
289341 Map <String , Object > extras = getNotificationExtras (intent );
290342 JPushPlugin .transmitNotificationReceive (title , alert , extras );
291343 }
292344
293345 private Map <String , Object > getNotificationExtras (Intent intent ) {
346+ Log .d (TAG ,"" );
347+
294348 Map <String , Object > extrasMap = new HashMap <String , Object >();
295349 for (String key : intent .getExtras ().keySet ()) {
296350 if (!IGNORED_EXTRAS_KEYS .contains (key )) {
@@ -307,6 +361,8 @@ private Map<String, Object> getNotificationExtras(Intent intent) {
307361
308362
309363 static void transmitMessageReceive (String message , Map <String , Object > extras ) {
364+ Log .d (TAG ,"transmitMessageReceive " + "message=" + message + "extras=" + extras );
365+
310366 if (instance == null ) {
311367 return ;
312368 }
@@ -318,6 +374,8 @@ static void transmitMessageReceive(String message, Map<String, Object> extras) {
318374 }
319375
320376 static void transmitNotificationOpen (String title , String alert , Map <String , Object > extras ) {
377+ Log .d (TAG ,"transmitNotificationOpen " + "title=" + title + "alert=" + alert + "extras=" + extras );
378+
321379 Map <String , Object > notification = new HashMap <>();
322380 notification .put ("title" , title );
323381 notification .put ("alert" , alert );
@@ -338,6 +396,8 @@ static void transmitNotificationOpen(String title, String alert, Map<String, Obj
338396 }
339397
340398 static void transmitNotificationReceive (String title , String alert , Map <String , Object > extras ) {
399+ Log .d (TAG ,"transmitNotificationReceive " + "title=" + title + "alert=" + alert + "extras=" + extras );
400+
341401 if (instance == null ) {
342402 return ;
343403 }
@@ -350,6 +410,8 @@ static void transmitNotificationReceive(String title, String alert, Map<String,
350410 }
351411
352412 static void transmitReceiveRegistrationId (String rId ) {
413+ Log .d (TAG ,"transmitReceiveRegistrationId: " + rId );
414+
353415 if (instance == null ) {
354416 return ;
355417 }
0 commit comments