NIMSDK-AOS  10.5.0
QChatLoginParam.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.qchat.param;
2 
3 import android.text.TextUtils;
4 
5 import androidx.annotation.NonNull;
6 
7 import com.netease.nimlib.SDKCache;
8 import com.netease.nimlib.SDKCacheUI;
10 
11 import java.util.List;
12 
16 public class QChatLoginParam {
17 
21  public interface QChatLoginCallback {
22 
28  List<String> getQChatLinkAddresses(final String account);
29  }
30 
34  private final QChatLoginCallback loginCallback;
35 
39  private final String account;
40 
44  private final String token;
48  private String appKey;
52  private final QChatAuthType _authType;
56  private String loginExt;
60  private Integer customClientType;
64  private String customPushContentType;
68  private String customTag;
69 
70 
76  public String getAppKey() {
77  return appKey;
78  }
79 
80 
86  public String getAccount() {
87  return account;
88  }
89 
95  public String getToken() {
96  return token;
97  }
98 
103  @NonNull
105  return _authType;
106  }
107 
112  public String getLoginExt() {
113  return loginExt;
114  }
115 
120  public void setLoginExt(String loginExt) {
121  this.loginExt = loginExt;
122  }
123 
128  public Integer getCustomClientType() {
129  return customClientType;
130  }
131 
136  public void setCustomClientType(int customClientType) {
137  this.customClientType = customClientType;
138  }
139 
144  public String getCustomTag() {
145  return customTag;
146  }
147 
152  public void setCustomTag(String customTag) {
153  this.customTag = customTag;
154  }
155 
160  public String getCustomPushContentType() {
161  return customPushContentType;
162  }
163 
168  public void setCustomPushContentType(String customPushContentType) {
169  this.customPushContentType = customPushContentType;
170  }
171 
177  return loginCallback;
178  }
179 
186  public QChatLoginParam() {
187  this.account = SDKCacheUI.getAuthInfo() == null ? "" : SDKCacheUI.getAuthInfo().getAccount();
188  this.token = SDKCacheUI.getAuthInfo() == null ? "" : SDKCacheUI.getAuthInfo().getToken();
189  this.appKey = SDKCache.getAppKey();
190 
191  int authType = SDKCacheUI.getAuthInfo() == null ? QChatAuthType.DEFAULT.getValue() : SDKCacheUI.getAuthInfo().getAuthType();
192  if (authType > QChatAuthType.DYNAMIC.getValue()) {
193  this._authType = QChatAuthType.DEFAULT;
194  } else {
195  this._authType = QChatAuthType.typeOfValue(authType);
196  }
197 
198  this.loginCallback = null;
199  }
200 
211  private QChatLoginParam(@NonNull String account, @NonNull String token, @NonNull String appKey, QChatAuthType authType, QChatLoginCallback callback) {
212  this.loginCallback = callback;
213  this.account = account;
214  this.token = token;
215  this.appKey = appKey;
216  this._authType = authType;
217  }
218 
223  public boolean isValid() {
224  if (_authType == QChatAuthType.DEFAULT) {
225  return !TextUtils.isEmpty(account) && !TextUtils.isEmpty(token) && !TextUtils.isEmpty(appKey);
226  }
227 
228  if (_authType == QChatAuthType.DYNAMIC) {
229  return !TextUtils.isEmpty(account) && !TextUtils.isEmpty(appKey);
230  }
231 
232  return false;
233  }
234 }
Integer getCustomClientType()
获取自定义客户端类型
String getCustomPushContentType()
获取自定义推送文案类型
void setCustomTag(String customTag)
设置自定义Tag
void setCustomPushContentType(String customPushContentType)
设置自定义推送文案类型,离线推送不显示详情时,要显示的文案对应的类型名称
List< String > getQChatLinkAddresses(final String account)
获取link地址列表
QChatLoginCallback getLoginCallback()
获取圈组登录独立模式回调
void setCustomClientType(int customClientType)
设置自定义客户端类型
QChatAuthType getAuthType()
获取鉴权方式
String getLoginExt()
获取登录自定义字段
static QChatAuthType typeOfValue(int value)
void setLoginExt(String loginExt)
设置登录自定义字段
QChatLoginParam()
非独立模式下,圈组登录参数的构造函数, 不需要传入account、token、appKey、authType、loginCallback acco...
boolean isValid()
数据是否有效,有效时才会进行登录操作,否则返回RES_EPARAM