4444import com .netease .nimlib .sdk .uinfo .UserInfoProvider ;
4545import com .netease .nimlib .sdk .util .NIMUtil ;
4646
47+
4748/**
4849 * Created by dowin on 2017/4/28.
4950 */
5051
5152public class IMApplication {
5253
5354
54- public static class MiPushConfig {
55-
56- public String certificate ;
57- public String appID ;
58- public String appKey ;
59-
60- /**
61- * 注册小米推送证书名称 、推送appID 以及在云信管理后台添加的appKey
62- */
63- public MiPushConfig (String certificate , String appID , String appKey ) {
64- this .certificate = certificate ;
65- this .appID = appID ;
66- this .appKey = appKey ;
67- }
68- }
55+ // public static class MiPushConfig {
56+ //
57+ // public String certificate;
58+ // public String appID;
59+ // public String appKey;
60+ //
61+ // /**
62+ // * 注册小米推送证书名称 、推送appID 以及在云信管理后台添加的appKey
63+ // */
64+ // public MiPushConfig(String certificate, String appID, String appKey) {
65+ // this.certificate = certificate;
66+ // this.appID = appID;
67+ // this.appKey = appKey;
68+ // }
69+ // }
6970
7071 // context
7172 private static Context context ;
@@ -87,21 +88,20 @@ public MiPushConfig(String certificate, String appID, String appKey) {
8788 private static StatusBarNotificationConfig statusBarNotificationConfig ;
8889 private static boolean DEBUG = false ;
8990
90- public static void init (Context context , Class mainActivityClass , @ DrawableRes int notify_msg_drawable_id , MiPushConfig miPushConfig ) {
91+ public static void init (Context context , Class mainActivityClass , @ DrawableRes int notify_msg_drawable_id , MixPushConfig miPushConfig ) {
9192 IMApplication .context = context .getApplicationContext ();
9293 IMApplication .mainActivityClass = mainActivityClass ;
9394 IMApplication .notify_msg_drawable_id = notify_msg_drawable_id ;
9495
9596 // 注册小米推送appID 、appKey 以及在云信管理后台添加的小米推送证书名称,该逻辑放在 NIMClient init 之前
96- if (miPushConfig != null ) {
97- MixPushConfig mixPushConfig = new MixPushConfig ();
98- mixPushConfig .xmCertificateName = miPushConfig .certificate ;
99- mixPushConfig .xmAppId = miPushConfig .appID ;
100- mixPushConfig .xmAppKey = miPushConfig .appKey ;
101- NIMPushClient .initPush (new MixPushConfig ());
102- }
103-
104- NIMClient .init (context , getLoginInfo (), getOptions (context ));
97+ // if (miPushConfig != null) {
98+ // MixPushConfig mixPushConfig = new MixPushConfig();
99+ // mixPushConfig.xmCertificateName = miPushConfig.certificate;
100+ // mixPushConfig.xmAppId = miPushConfig.appID;
101+ // mixPushConfig.xmAppKey = miPushConfig.appKey;
102+ // NIMPushClient.initPush(new MixPushConfig());
103+ // }
104+ NIMClient .init (context , getLoginInfo (), getOptions (context , miPushConfig ));
105105 // crash handler
106106// AppCrashHandler.getInstance(context);
107107 if (NIMUtil .isMainProcess (IMApplication .context )) {
@@ -161,7 +161,7 @@ public static String getSdkStorageRooPath() {
161161 return Environment .getExternalStorageDirectory () + "/" + context .getPackageName () + "/nim" ;
162162 }
163163
164- private static SDKOptions getOptions (Context context ) {
164+ private static SDKOptions getOptions (Context context , MixPushConfig miPushConfig ) {
165165 SDKOptions options = new SDKOptions ();
166166
167167 // 如果将新消息通知提醒托管给SDK完成,需要添加以下配置。
@@ -195,6 +195,11 @@ private static SDKOptions getOptions(Context context) {
195195 //teamNotificationMessageMarkUnread 登录选项添加群通知消息是否计入未读数开关
196196 //sdkStorageRootPath 配置的外置存储缓存根目录
197197
198+ // 推送配置
199+ if (miPushConfig !=null ) {
200+ options .mixPushConfig = miPushConfig ;
201+ }
202+
198203 return options ;
199204 }
200205
0 commit comments