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