1package com.netease.nimlib.sdk.mixpush;
4import android.content.Context;
5import androidx.annotation.Nullable;
6import com.netease.nimlib.annotation.Keep;
7import com.netease.nimlib.log.NimLog;
8import com.netease.nimlib.mixpush.MixPushCache;
9import com.netease.nimlib.mixpush.TokenCallback;
10import com.netease.nimlib.mixpush.model.MixPushTokenImpl;
11import com.netease.nimlib.mixpush.platforms.MixPushPlatforms;
12import com.netease.nimlib.notifier.NotificationChannelCompat;
13import com.netease.nimlib.sdk.StatusBarNotificationConfig;
19@SuppressWarnings(
"java:S1144")
22 private static final String TAG =
"NIMPushClient";
29 MixPushCache.init(config);
37 MixPushCache.setMixPushMessageHandler(handler);
51 if(MixPushCache.getContext() ==
null){
52 MixPushCache.setContext(context);
54 if(MixPushCache.getNotificationConfig() ==
null){
55 MixPushCache.setNotificationConfig(notificationConfig);
58 NotificationChannelCompat.createNIMMessageNotificationChannel(context,MixPushCache.getNotificationConfig());
59 TokenCallback tokenCallback =
new TokenCallback(){
61 public void onToken(@Nullable MixPushTokenImpl pushToken) {
62 if (pushToken ==
null || pushToken.isNotValid()) {
64 NimLog.i(TAG,
"getPushToken, reason: token null");
68 if (pushToken.getType() != requestPushType) {
70 NimLog.i(TAG,
"getPushToken, reason: token type not match");
77 MixPushConfig config = MixPushCache.getMixPushConfig();
78 if (config ==
null || !config.autoSelectPushType) {
79 MixPushPlatforms.registerPushSDK(context, requestPushType, tokenCallback);
81 MixPushPlatforms.registerAllPush(context, tokenCallback);
Created by chenkang on 2017/11/20.
static void initPush(MixPushConfig config)
static void registerMixPushMessageHandler(MixPushMessageHandler handler)
注册第三方推送消息接收handler 在云信SDK初始化 NimClient.init 接口前调用
void onSuccess(T result)
操作成功
第三方推送消息回调接口,用户如果需要自行处理云信的第三方推送消息,则可实现该接口,并注册到NIMPushClient