|
|
@@ -7,11 +7,10 @@ import android.text.TextUtils;
|
|
|
import com.atmob.common.data.KVUtils;
|
|
|
import com.atmob.common.logging.AtmobLog;
|
|
|
import com.atmob.common.runtime.ContextUtil;
|
|
|
-import com.atmob.common.runtime.ProcessUtil;
|
|
|
-import com.atmob.user.AtmobUser;
|
|
|
import com.datarecovery.master.BuildConfig;
|
|
|
import com.datarecovery.master.R;
|
|
|
import com.datarecovery.master.data.repositories.AccountRepository;
|
|
|
+import com.datarecovery.master.utils.SystemUtil;
|
|
|
import com.qiyukf.nimlib.sdk.RequestCallback;
|
|
|
import com.qiyukf.nimlib.sdk.StatusBarNotificationConfig;
|
|
|
import com.qiyukf.unicorn.api.Unicorn;
|
|
|
@@ -22,6 +21,7 @@ import java.util.UUID;
|
|
|
|
|
|
public class QiYuHelper {
|
|
|
|
|
|
+ private static final String TAG = "QiYuHelper";
|
|
|
|
|
|
private static final String ysfAppId = BuildConfig.QIYU_APP_KEY;
|
|
|
private static final String VISITOR_KEY = "visitor_key";
|
|
|
@@ -45,21 +45,22 @@ public class QiYuHelper {
|
|
|
// CRM 扩展字段
|
|
|
userInfo.data = "[\n" +
|
|
|
" {\"key\":\"real_name\", \"value\":\"" + appName + "\"},\n" +
|
|
|
+ getAppCommonInfo() +
|
|
|
"]";
|
|
|
Unicorn.setUserInfo(userInfo, new RequestCallback<Void>() {
|
|
|
@Override
|
|
|
public void onSuccess(Void aVoid) {
|
|
|
- AtmobLog.d("zk", "set visitor info success");
|
|
|
+ AtmobLog.d(TAG, "set visitor info success");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFailed(int errorCode) {
|
|
|
- AtmobLog.d("zk", "set visitor info failed, errorCode: " + errorCode);
|
|
|
+ AtmobLog.d(TAG, "set visitor info failed, errorCode: " + errorCode);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onException(Throwable throwable) {
|
|
|
- AtmobLog.d("zk", "set visitor info exception: " + throwable.getMessage());
|
|
|
+ AtmobLog.d(TAG, "set visitor info exception: " + throwable.getMessage());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -73,6 +74,7 @@ public class QiYuHelper {
|
|
|
|
|
|
public static void logout() {
|
|
|
Unicorn.logout();
|
|
|
+ KVUtils.getDefault().putString(VISITOR_KEY, null);
|
|
|
}
|
|
|
|
|
|
public static void openServiceActivity(Context context) {
|
|
|
@@ -88,7 +90,7 @@ public class QiYuHelper {
|
|
|
return userId;
|
|
|
}
|
|
|
|
|
|
- public static void setUserInfo(String phone, String token) {
|
|
|
+ public static void setUserInfo(String phone, String serverUserId, String token) {
|
|
|
YSFUserInfo userInfo = new YSFUserInfo();
|
|
|
// App 的用户 ID
|
|
|
userInfo.userId = getUserId();
|
|
|
@@ -99,22 +101,31 @@ public class QiYuHelper {
|
|
|
userInfo.data = "[\n" +
|
|
|
" {\"key\":\"real_name\", \"value\":\"" + appName + "\"},\n" +
|
|
|
" {\"key\":\"mobile_phone\", \"hidden\":false, \"value\":\"" + phone + "\"},\n" +
|
|
|
+ " {\"index\":0, \"key\":\"version\", \"label\":\"用户Id\", \"value\":\"" + serverUserId + "\" },\n" +
|
|
|
+ getAppCommonInfo() +
|
|
|
"]";
|
|
|
Unicorn.setUserInfo(userInfo, new RequestCallback<Void>() {
|
|
|
@Override
|
|
|
public void onSuccess(Void aVoid) {
|
|
|
- AtmobLog.d("zk", "set visitor info success");
|
|
|
+ AtmobLog.d(TAG, "set visitor info success");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFailed(int errorCode) {
|
|
|
- AtmobLog.d("zk", "set visitor info failed, errorCode: " + errorCode);
|
|
|
+ AtmobLog.d(TAG, "set visitor info failed, errorCode: " + errorCode);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onException(Throwable throwable) {
|
|
|
- AtmobLog.d("zk", "set visitor info exception: " + throwable.getMessage());
|
|
|
+ AtmobLog.d(TAG, "set visitor info exception: " + throwable.getMessage());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ private static String getAppCommonInfo() {
|
|
|
+ String info = " {\"index\":1, \"key\":\"version\", \"label\":\"应用版本\", \"value\":\"v" + SystemUtil.getVersionName(ContextUtil.getContext()) + "\" },\n" +
|
|
|
+ " {\"index\":2, \"key\":\"appName\", \"label\":\"应用名称\", \"value\":\"" + ContextUtil.getContext().getString(R.string.app_name) + "\" },\n" +
|
|
|
+ " {\"index\":3, \"key\":\"packageName\", \"label\":\"包名\", \"value\":\"" + ContextUtil.getApplication().getPackageName() + "\" },\n";
|
|
|
+ return info;
|
|
|
+ }
|
|
|
}
|