@@ -33,6 +33,7 @@ public static void registerWith(Registrar registrar) {
33
33
34
34
}
35
35
36
+ private static String TAG = "| JPUSH | Android | " ;
36
37
public static JPushPlugin instance ;
37
38
static List <Map <String , Object >> openNotificationCache = new ArrayList <>();
38
39
@@ -60,6 +61,7 @@ private JPushPlugin(Registrar registrar, MethodChannel channel) {
60
61
61
62
@ Override
62
63
public void onMethodCall (MethodCall call , Result result ) {
64
+ Log .i (TAG ,call .method );
63
65
if (call .method .equals ("getPlatformVersion" )) {
64
66
result .success ("Android " + android .os .Build .VERSION .RELEASE );
65
67
} else if (call .method .equals ("setup" )) {
@@ -90,12 +92,17 @@ public void onMethodCall(MethodCall call, Result result) {
90
92
getRegistrationID (call , result );
91
93
} else if (call .method .equals ("sendLocalNotification" )) {
92
94
sendLocalNotification (call , result );
93
- } else {
95
+ } else if (call .method .equals ("setBadge" )) {
96
+ setBadge (call , result );
97
+ }
98
+ else {
94
99
result .notImplemented ();
95
100
}
96
101
}
97
102
98
103
public void setup (MethodCall call , Result result ) {
104
+ Log .d (TAG ,"setup :" + call .arguments );
105
+
99
106
HashMap <String , Object > map = call .arguments ();
100
107
boolean debug = (boolean )map .get ("debug" );
101
108
JPushInterface .setDebugMode (debug );
@@ -112,6 +119,8 @@ public void setup(MethodCall call, Result result) {
112
119
}
113
120
114
121
public void scheduleCache () {
122
+ Log .d (TAG ,"scheduleCache:" );
123
+
115
124
if (dartIsReady ) {
116
125
// try to shedule notifcation cache
117
126
for (Map <String , Object > notification : JPushPlugin .openNotificationCache ) {
@@ -131,6 +140,8 @@ public void scheduleCache() {
131
140
}
132
141
133
142
public void setTags (MethodCall call , Result result ) {
143
+ Log .d (TAG ,"setTags:" );
144
+
134
145
List <String >tagList = call .arguments ();
135
146
Set <String > tags = new HashSet <>(tagList );
136
147
sequence += 1 ;
@@ -139,12 +150,16 @@ public void setTags(MethodCall call, Result result) {
139
150
}
140
151
141
152
public void cleanTags (MethodCall call , Result result ) {
153
+ Log .d (TAG ,"cleanTags:" );
154
+
142
155
sequence += 1 ;
143
156
callbackMap .put (sequence , result );
144
157
JPushInterface .cleanTags (registrar .context (), sequence );
145
158
}
146
159
147
160
public void addTags (MethodCall call , Result result ) {
161
+ Log .d (TAG ,"addTags: " + call .arguments );
162
+
148
163
List <String >tagList = call .arguments ();
149
164
Set <String > tags = new HashSet <>(tagList );
150
165
sequence += 1 ;
@@ -153,6 +168,8 @@ public void addTags(MethodCall call, Result result) {
153
168
}
154
169
155
170
public void deleteTags (MethodCall call , Result result ) {
171
+ Log .d (TAG ,"deleteTags: " + call .arguments );
172
+
156
173
List <String >tagList = call .arguments ();
157
174
Set <String > tags = new HashSet <>(tagList );
158
175
sequence += 1 ;
@@ -161,42 +178,57 @@ public void deleteTags(MethodCall call, Result result) {
161
178
}
162
179
163
180
public void getAllTags (MethodCall call , Result result ) {
181
+ Log .d (TAG ,"getAllTags: " );
182
+
164
183
sequence += 1 ;
165
184
callbackMap .put (sequence , result );
166
185
JPushInterface .getAllTags (registrar .context (), sequence );
167
186
}
168
187
169
188
public void setAlias (MethodCall call , Result result ) {
189
+ Log .d (TAG ,"setAlias: " + call .arguments );
190
+
170
191
String alias = call .arguments ();
171
192
sequence += 1 ;
172
193
callbackMap .put (sequence , result );
173
194
JPushInterface .setAlias (registrar .context (), sequence , alias );
174
195
}
175
196
176
197
public void deleteAlias (MethodCall call , Result result ) {
198
+ Log .d (TAG ,"deleteAlias:" );
199
+
177
200
String alias = call .arguments ();
178
201
sequence += 1 ;
179
202
callbackMap .put (sequence , result );
180
203
JPushInterface .deleteAlias (registrar .context (), sequence );
181
204
}
182
205
183
206
public void stopPush (MethodCall call , Result result ) {
207
+ Log .d (TAG ,"stopPush:" );
208
+
184
209
JPushInterface .stopPush (registrar .context ());
185
210
}
186
211
187
212
public void resumePush (MethodCall call , Result result ) {
213
+ Log .d (TAG ,"resumePush:" );
214
+
188
215
JPushInterface .resumePush (registrar .context ());
189
216
}
190
217
191
218
public void clearAllNotifications (MethodCall call , Result result ) {
219
+ Log .d (TAG ,"clearAllNotifications: " );
220
+
192
221
JPushInterface .clearAllNotifications (registrar .context ());
193
222
}
194
223
195
224
public void getLaunchAppNotification (MethodCall call , Result result ) {
225
+ Log .d (TAG ,"" );
226
+
196
227
197
228
}
198
229
199
230
public void getRegistrationID (MethodCall call , Result result ) {
231
+ Log .d (TAG ,"getRegistrationID: " );
200
232
201
233
String rid = JPushInterface .getRegistrationID (registrar .context ());
202
234
if (rid == null || rid .isEmpty ()) {
@@ -208,6 +240,8 @@ public void getRegistrationID(MethodCall call, Result result) {
208
240
209
241
210
242
public void sendLocalNotification (MethodCall call , Result result ) {
243
+ Log .d (TAG ,"sendLocalNotification: " + call .arguments );
244
+
211
245
try {
212
246
HashMap <String , Object > map = call .arguments ();
213
247
@@ -232,6 +266,17 @@ public void sendLocalNotification(MethodCall call, Result result) {
232
266
}
233
267
}
234
268
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
+ }
235
280
236
281
/**
237
282
* 接收自定义消息,通知,通知点击事件等事件的广播
@@ -248,6 +293,7 @@ public JPushReceiver() {
248
293
@ Override
249
294
public void onReceive (Context context , Intent intent ) {
250
295
String action = intent .getAction ();
296
+
251
297
if (action .equals (JPushInterface .ACTION_REGISTRATION_ID )) {
252
298
String rId = intent .getStringExtra (JPushInterface .EXTRA_REGISTRATION_ID );
253
299
Log .d ("JPushPlugin" ,"on get registration" );
@@ -264,12 +310,16 @@ public void onReceive(Context context, Intent intent) {
264
310
}
265
311
266
312
private void handlingMessageReceive (Intent intent ) {
313
+ Log .d (TAG ,"handlingMessageReceive " + intent .getAction ());
314
+
267
315
String msg = intent .getStringExtra (JPushInterface .EXTRA_MESSAGE );
268
316
Map <String , Object > extras = getNotificationExtras (intent );
269
317
JPushPlugin .transmitMessageReceive (msg , extras );
270
318
}
271
319
272
320
private void handlingNotificationOpen (Context context , Intent intent ) {
321
+ Log .d (TAG ,"handlingNotificationOpen " + intent .getAction ());
322
+
273
323
String title = intent .getStringExtra (JPushInterface .EXTRA_NOTIFICATION_TITLE );
274
324
String alert = intent .getStringExtra (JPushInterface .EXTRA_ALERT );
275
325
Map <String , Object > extras = getNotificationExtras (intent );
@@ -284,13 +334,17 @@ private void handlingNotificationOpen(Context context, Intent intent) {
284
334
}
285
335
286
336
private void handlingNotificationReceive (Context context , Intent intent ) {
337
+ Log .d (TAG ,"handlingNotificationReceive " + intent .getAction ());
338
+
287
339
String title = intent .getStringExtra (JPushInterface .EXTRA_NOTIFICATION_TITLE );
288
340
String alert = intent .getStringExtra (JPushInterface .EXTRA_ALERT );
289
341
Map <String , Object > extras = getNotificationExtras (intent );
290
342
JPushPlugin .transmitNotificationReceive (title , alert , extras );
291
343
}
292
344
293
345
private Map <String , Object > getNotificationExtras (Intent intent ) {
346
+ Log .d (TAG ,"" );
347
+
294
348
Map <String , Object > extrasMap = new HashMap <String , Object >();
295
349
for (String key : intent .getExtras ().keySet ()) {
296
350
if (!IGNORED_EXTRAS_KEYS .contains (key )) {
@@ -307,6 +361,8 @@ private Map<String, Object> getNotificationExtras(Intent intent) {
307
361
308
362
309
363
static void transmitMessageReceive (String message , Map <String , Object > extras ) {
364
+ Log .d (TAG ,"transmitMessageReceive " + "message=" + message + "extras=" + extras );
365
+
310
366
if (instance == null ) {
311
367
return ;
312
368
}
@@ -318,6 +374,8 @@ static void transmitMessageReceive(String message, Map<String, Object> extras) {
318
374
}
319
375
320
376
static void transmitNotificationOpen (String title , String alert , Map <String , Object > extras ) {
377
+ Log .d (TAG ,"transmitNotificationOpen " + "title=" + title + "alert=" + alert + "extras=" + extras );
378
+
321
379
Map <String , Object > notification = new HashMap <>();
322
380
notification .put ("title" , title );
323
381
notification .put ("alert" , alert );
@@ -338,6 +396,8 @@ static void transmitNotificationOpen(String title, String alert, Map<String, Obj
338
396
}
339
397
340
398
static void transmitNotificationReceive (String title , String alert , Map <String , Object > extras ) {
399
+ Log .d (TAG ,"transmitNotificationReceive " + "title=" + title + "alert=" + alert + "extras=" + extras );
400
+
341
401
if (instance == null ) {
342
402
return ;
343
403
}
@@ -350,6 +410,8 @@ static void transmitNotificationReceive(String title, String alert, Map<String,
350
410
}
351
411
352
412
static void transmitReceiveRegistrationId (String rId ) {
413
+ Log .d (TAG ,"transmitReceiveRegistrationId: " + rId );
414
+
353
415
if (instance == null ) {
354
416
return ;
355
417
}
0 commit comments