NIMSDK-AOS  9.16.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;
9 
10 import java.util.List;
11 
15 public class QChatLoginParam {
16 
20  public interface QChatLoginCallback {
21 
27  List<String> getQChatLinkAddresses(final String account);
28  }
29 
33  private final QChatLoginCallback loginCallback;
34 
38  private final String account;
39 
43  private final String token;
47  private String appKey;
51  private final QChatAuthType authType;
55  private String loginExt;
59  private Integer customClientType;
63  private String customPushContentType;
67  private String customTag;
68 
69 
75  public String getAppKey() {
76  return appKey;
77  }
78 
79 
85  public String getAccount() {
86  return account;
87  }
88 
94  public String getToken() {
95  return token;
96  }
97 
102  @NonNull
104  return authType;
105  }
106 
111  public String getLoginExt() {
112  return loginExt;
113  }
114 
119  public void setLoginExt(String loginExt) {
120  this.loginExt = loginExt;
121  }
122 
127  public Integer getCustomClientType() {
128  return customClientType;
129  }
130 
135  public void setCustomClientType(int customClientType) {
136  this.customClientType = customClientType;
137  }
138 
143  public String getCustomTag() {
144  return customTag;
145  }
146 
151  public void setCustomTag(String customTag) {
152  this.customTag = customTag;
153  }
154 
159  public String getCustomPushContentType() {
160  return customPushContentType;
161  }
162 
167  public void setCustomPushContentType(String customPushContentType) {
168  this.customPushContentType = customPushContentType;
169  }
170 
176  return loginCallback;
177  }
178 
185  public QChatLoginParam() {
186  this.account = SDKCache.getAuthInfo() == null ? "" : SDKCache.getAuthInfo().getAccount();
187  this.token = SDKCache.getAuthInfo() == null ? "" : SDKCache.getAuthInfo().getToken();
188  this.appKey = SDKCache.getAppKey();
189 
190  int authType = SDKCache.getAuthInfo() == null ? QChatAuthType.DEFAULT.getValue() : SDKCache.getAuthInfo().getAuthType();
191  if (authType > QChatAuthType.DYNAMIC.getValue()) {
192  this.authType = QChatAuthType.DEFAULT;
193  } else {
194  this.authType = QChatAuthType.typeOfValue(authType);
195  }
196 
197  this.loginCallback = null;
198  }
199 
210  private QChatLoginParam(@NonNull String account, @NonNull String token, @NonNull String appKey, QChatAuthType authType, QChatLoginCallback callback) {
211  this.loginCallback = callback;
212  this.account = account;
213  this.token = token;
214  this.appKey = appKey;
215  this.authType = authType;
216  }
217 
222  public boolean isValid() {
223  if (authType == QChatAuthType.DEFAULT) {
224  return !TextUtils.isEmpty(account) && !TextUtils.isEmpty(token) && !TextUtils.isEmpty(appKey);
225  }
226 
227  if (authType == QChatAuthType.DYNAMIC) {
228  return !TextUtils.isEmpty(account) && !TextUtils.isEmpty(appKey);
229  }
230 
231  return false;
232  }
233 }
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