admin
2021-02-27 db66b085308b8bc7a1ff9440c85895d41c98b5ed
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package com.weikou.beibeivideo.receiver;
 
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
 
import com.meizu.cloud.pushsdk.MzPushMessageReceiver;
import com.meizu.cloud.pushsdk.PushManager;
import com.meizu.cloud.pushsdk.handler.MzPushMessage;
import com.meizu.cloud.pushsdk.platform.message.PushSwitchStatus;
import com.meizu.cloud.pushsdk.platform.message.RegisterStatus;
import com.meizu.cloud.pushsdk.platform.message.SubAliasStatus;
import com.meizu.cloud.pushsdk.platform.message.SubTagsStatus;
import com.meizu.cloud.pushsdk.platform.message.UnRegisterStatus;
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.ui.SplashActivity;
import com.xiaomi.mipush.sdk.ErrorCode;
import com.xiaomi.mipush.sdk.MiPushClient;
import com.xiaomi.mipush.sdk.MiPushCommandMessage;
import com.xiaomi.mipush.sdk.MiPushMessage;
import com.xiaomi.mipush.sdk.PushMessageReceiver;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
import java.util.List;
 
public class MZPushMessageReceiver extends MzPushMessageReceiver {
    private final String TAG=MZPushMessageReceiver.class.getSimpleName();
    /**
     * 调用订阅方法后,会在此方法回调结果
     * 订阅方法:PushManager.register(context, appId, appKey)
     *
     * @param context
     * @param registerStatus
     */
    @Override
    public void onRegisterStatus(Context context, RegisterStatus registerStatus) {
        Log.i(TAG,"onRegisterStatus");
        String pushId = registerStatus.getPushId();
        BeibeiVideoAPI.pushBindToken(context, "mz", pushId, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
 
            }
        },true);
    }
 
    /**
     * 调用取消订阅方法后,会在此方法回调结果
     * 取消订阅方法:PushManager.unRegister(context, appId, appKey)
     *
     * @param context
     * @param unRegisterStatus
     */
    @Override
    public void onUnRegisterStatus(Context context, UnRegisterStatus unRegisterStatus) {
        Log.i(TAG,"onUnRegisterStatus");
    }
 
    /**
     * 调用开关转换或检查开关状态方法后,会在此方法回调开关状态
     * 通知栏开关转换方法:PushManager.switchPush(context, appId, appKey, pushId, pushType, switcher)
     * 检查开关状态方法:PushManager.checkPush(context, appId, appKey, pushId)
     *
     * @param context
     * @param pushSwitchStatus
     */
    @Override
    public void onPushStatus(Context context, PushSwitchStatus pushSwitchStatus) {
        Log.i(TAG,"onPushStatus");
    }
 
    /**
     * 调用标签订阅、取消标签订阅、取消所有标签订阅和获取标签列表方法后,会在此方法回调标签相关信息
     * 标签订阅方法:PushManager.subScribeTags(context, appId, appKey, pushId, tags)
     * 取消标签订阅方法:PushManager.unSubScribeTags(context, appId, appKey, pushId,tags)
     * 取消所有标签订阅方法:PushManager.unSubScribeAllTags(context, appId, appKey, pushId)
     * 获取标签列表方法:PushManager.checkSubScribeTags(context, appId, appKey, pushId)
     *
     * @param context
     * @param subTagsStatus
     */
    @Override
    public void onSubTagsStatus(Context context, SubTagsStatus subTagsStatus) {
        Log.i(TAG,"onSubTagsStatus");
    }
 
    /**
     * 调用别名订阅、取消别名订阅和获取别名方法后,会在此方法回调别名相关信息
     * 别名订阅方法:PushManager.subScribeAlias(context, appId, appKey, pushId, alias)
     * 取消别名订阅方法:PushManager.unSubScribeAlias(context, appId, appKey, pushId, alias)
     * 获取别名方法:PushManager.checkSubScribeAlias(context, appId, appKey, pushId)
     *
     * @param context
     * @param subAliasStatus
     */
    @Override
    public void onSubAliasStatus(Context context, SubAliasStatus subAliasStatus) {
        Log.i(TAG,"onSubAliasStatus");
    }
 
    /**
     * 当用户点击通知栏消息后会在此方法回调
     *
     * @param context
     * @param mzPushMessage
     */
    @Override
    public void onNotificationClicked(Context context, MzPushMessage mzPushMessage) {
        Log.i(TAG,"onNotificationClicked");
 
        PushManager.getPushId(context);
 
    }
 
    /**
     * 当推送的通知栏消息展示后且应用进程存在时会在此方法回调
     *
     * @param context
     * @param mzPushMessage
     */
    @Override
    public void onNotificationArrived(Context context, MzPushMessage mzPushMessage) {
        Log.i(TAG,"onNotificationArrived");
    }
}