/
XGCordova.java
44 lines (34 loc) · 1.27 KB
/
XGCordova.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.eteng.push.xgpush2;
import org.apache.cordova.CallbackContext;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushManager;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
public class XGCordova extends XGPushPlugin {
private static final String TAG = "XGCordovaPlugin";
private ReceiverManager manager = new ReceiverManager();
@Override
protected boolean registerPush(Context context, String alias, CallbackContext callback) {
Log.d(TAG, "> register: " + alias);
XGIOperateCallback reply = new XGCordovaOperateCallback(callback);
if (TextUtils.isEmpty(alias)) {
Log.d(TAG, "> register public");
XGPushManager.registerPush(context, reply);
} else {
Log.d(TAG, "> register private");
XGPushManager.registerPush(context, alias, reply);
}
return true;
}
@Override
protected boolean unregisterPush(Context context, CallbackContext callback) {
XGIOperateCallback reply = new XGCordovaOperateCallback(callback);
XGPushManager.unregisterPush(context, reply);
return true;
}
@Override
protected boolean addListener(Context context, CallbackContext callback) {
return manager.registerReceiver(context, callback);
}
}