NIMSDK-AOS 10.4.0-beta
载入中...
搜索中...
未找到
MixPushConfig.java
浏览该文件的文档.
1package com.netease.nimlib.sdk.mixpush;
2
3import androidx.annotation.Nullable;
4import java.io.Serializable;
5import org.json.JSONException;
6import org.json.JSONObject;
7
8/**
9 * Created by chenkang on 2017/11/20.
10 */
11
12public class MixPushConfig implements Serializable {
13 public static final String KEY_XM_APP_ID = "KEY_XM_APP_ID";
14 public static final String KEY_XM_APP_KEY = "KEY_XM_APP_KEY";
15 public static final String KEY_XM_CERTIFICATE_NAME = "KEY_XM_CERTIFICATE_NAME";
16 public static final String KEY_HW_APP_ID = "KEY_HW_APP_ID";
17 public static final String KEY_HW_CERTIFICATE_NAME = "KEY_HW_CERTIFICATE_NAME";
18 public static final String KEY_MZ_APP_ID = "KEY_MZ_APP_ID";
19 public static final String KEY_MZ_APP_KEY = "KEY_MZ_APP_KEY";
20 public static final String KEY_MZ_CERTIFICATE_NAME = "KEY_MZ_CERTIFICATE_NAME";
21 public static final String KEY_FCM_CERTIFICATE_NAME = "KEY_FCM_CERTIFICATE_NAME";
22 public static final String KEY_VIVO_CERTIFICATE_NAME = "KEY_VIVO_CERTIFICATE_NAME";
23 public static final String KEY_OPPO_APP_ID = "KEY_OPPO_APP_ID";
24 public static final String KEY_OPPO_APP_KEY = "KEY_OPPO_APP_KEY";
25 public static final String KEY_OPPO_APP_SERCET = "KEY_OPPO_APP_SERCET";
26 public static final String KEY_OPPO_CERTIFICATE_NAME = "KEY_OPPO_CERTIFICATE_NAME";
27 public static final String KEY_AUTO_SELECT_PUSH_TYPE = "KEY_AUTO_SELECT_PUSH_TYPE";
28 public static final String KEY_HONOR_CERTIFICATE_NAME = "KEY_HONOR_CERTIFICATE_NAME";
29
30 /**
31 * 小米推送 appId
32 */
33 public String xmAppId;
34
35 /**
36 * 小米推送 appKey
37 */
38 public String xmAppKey;
39
40 /**
41 * 小米推送证书,请在云信管理后台申请
42 */
43 public String xmCertificateName;
44
45 /**
46 * 华为推送 hwAppId
47 */
48 public String hwAppId;
49
50 /**
51 *
52 * 华为推送证书,请在云信管理后台申请
53 */
54 public String hwCertificateName;
55
56 /**
57 * 魅族推送 appId
58 */
59 public String mzAppId;
60
61 /**
62 * 魅族推送 appKey
63 */
64 public String mzAppKey;
65
66 /**
67 * 魅族推送证书,请在云信管理后台申请
68 */
69 public String mzCertificateName;
70
71 /**
72 * FCM 推送证书,请在云信管理后台申请
73 * 海外客户使用
74 */
75 public String fcmCertificateName;
76
77 /**
78 * VIVO推送 appId apiKey请在 AndroidManifest.xml 文件中配置
79 * VIVO推送证书,请在云信管理后台申请
80 */
81 public String vivoCertificateName;
82
83 /**
84 * oppo 推送appId
85 */
86 public String oppoAppId;
87
88 /**
89 * oppo 推送appKey
90 */
91 public String oppoAppKey;
92
93 /**
94 * oppo 推送AppSecret
95 */
96 public String oppoAppSercet;
97
98 /**
99 * OPPO推送证书,请在云信管理后台申请
100 */
101 public String oppoCertificateName;
102
103 /**
104 * 荣耀推送 appId请在 AndroidManifest.xml 文件中配置
105 * 荣耀推送证书,请在云信管理后台申请
106 */
107 public String honorCertificateName;
108
109 /**
110 * 是否根据token自动选择推送类型
111 */
112 public boolean autoSelectPushType = false;
113
114
115 public JSONObject toJson() {
116 JSONObject object = new JSONObject();
117
118 try {
119 object.putOpt(KEY_XM_APP_ID, xmAppId);
120 object.putOpt(KEY_XM_APP_KEY, xmAppKey);
122 object.putOpt(KEY_HW_APP_ID, hwAppId);
124 object.putOpt(KEY_MZ_APP_ID, mzAppId);
125 object.putOpt(KEY_MZ_APP_KEY, mzAppKey);
129 object.putOpt(KEY_OPPO_APP_ID, oppoAppId);
130 object.putOpt(KEY_OPPO_APP_KEY, oppoAppKey);
131 object.putOpt(KEY_OPPO_APP_SERCET, oppoAppSercet);
135 } catch (JSONException e) {
136 e.printStackTrace();
137 }
138 return object;
139 }
140
141 public static MixPushConfig fromJson(@Nullable JSONObject object) {
142 if (object == null) {
143 return null;
144 }
145 MixPushConfig config = new MixPushConfig();
146
147 config.xmAppId = object.optString(KEY_XM_APP_ID, null);
148 config.xmAppKey = object.optString(KEY_XM_APP_KEY, null);
149 config.xmCertificateName = object.optString(KEY_XM_CERTIFICATE_NAME, null);
150 config.hwAppId = object.optString(KEY_HW_APP_ID, null);
151 config.hwCertificateName = object.optString(KEY_HW_CERTIFICATE_NAME, null);
152 config.mzAppId = object.optString(KEY_MZ_APP_ID, null);
153 config.mzAppKey = object.optString(KEY_MZ_APP_KEY, null);
154 config.mzCertificateName = object.optString(KEY_MZ_CERTIFICATE_NAME, null);
155 config.fcmCertificateName = object.optString(KEY_FCM_CERTIFICATE_NAME, null);
156 config.vivoCertificateName = object.optString(KEY_VIVO_CERTIFICATE_NAME, null);
157 config.oppoAppId = object.optString(KEY_OPPO_APP_ID, null);
158 config.oppoAppKey = object.optString(KEY_OPPO_APP_KEY, null);
159 config.oppoAppSercet = object.optString(KEY_OPPO_APP_SERCET, null);
160 config.oppoCertificateName = object.optString(KEY_OPPO_CERTIFICATE_NAME, null);
161 config.autoSelectPushType = object.optBoolean(KEY_AUTO_SELECT_PUSH_TYPE, false);
162 config.honorCertificateName = object.optString(KEY_HONOR_CERTIFICATE_NAME, null);
163 return config;
164 }
165
166}
Created by chenkang on 2017/11/20.
boolean autoSelectPushType
是否根据token自动选择推送类型
String fcmCertificateName
FCM 推送证书,请在云信管理后台申请 海外客户使用
String vivoCertificateName
VIVO推送 appId apiKey请在 AndroidManifest.xml 文件中配置 VIVO推送证书,请在云信管理后台申请
String honorCertificateName
荣耀推送 appId请在 AndroidManifest.xml 文件中配置 荣耀推送证书,请在云信管理后台申请
String xmCertificateName
小米推送证书,请在云信管理后台申请
static MixPushConfig fromJson(@Nullable JSONObject object)
String mzCertificateName
魅族推送证书,请在云信管理后台申请
String oppoCertificateName
OPPO推送证书,请在云信管理后台申请
String hwCertificateName
华为推送证书,请在云信管理后台申请