Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
acca90cd
Commit
acca90cd
authored
Mar 06, 2020
by
konghaorui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充云信初始化参数接口
parent
c0443700
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
69 deletions
+202
-69
config.gradle
config.gradle
+6
-6
NimApplication.java
m-im/src/main/java/com/yidianling/im/config/NimApplication.java
+4
-4
NimSDKOptionConfig.java
m-im/src/main/java/com/yidianling/im/config/NimSDKOptionConfig.java
+96
-57
IMServiceImpl.kt
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
+9
-2
IMInitConfigBean.java
m-im/src/main/modular_api/com/yidianling/im/api/bean/IMInitConfigBean.java
+83
-0
IImService.kt
m-im/src/main/modular_api/com/yidianling/im/api/service/IImService.kt
+4
-0
No files found.
config.gradle
View file @
acca90cd
ext
{
kotlin_version
=
"1.3.21"
dev_mode
=
tru
e
dev_mode
=
fals
e
ydl_app
=
[
appName
:
"心理咨询壹点灵"
,
...
...
@@ -47,7 +47,7 @@ ext {
"m-fm"
:
"0.0.29.2"
,
"m-user"
:
"0.0.59.5"
,
"m-home"
:
"0.0.20.3"
,
"m-im"
:
"0.0.15.
5
"
,
"m-im"
:
"0.0.15.
7
"
,
"m-dynamic"
:
"0.0.7.3"
,
"m-muse"
:
"0.0.28.8"
,
...
...
@@ -64,12 +64,12 @@ ext {
"m-tests-api"
:
"0.0.2"
,
"m-user-api"
:
"0.0.10.15"
,
"m-home-api"
:
"0.0.4.1"
,
"m-im-api"
:
"0.0.12.1
7
"
,
"m-im-api"
:
"0.0.12.1
8
"
,
"m-dynamic-api"
:
"0.0.3.7"
,
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.
4
"
,
"ydl-platform"
:
"0.0.39.
5
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.4"
,
...
...
@@ -110,12 +110,12 @@ ext {
"m-tests-api"
:
"0.0.2"
,
"m-user-api"
:
"0.0.10.15"
,
"m-home-api"
:
"0.0.4.1"
,
"m-im-api"
:
"0.0.12.1
7
"
,
"m-im-api"
:
"0.0.12.1
8
"
,
"m-dynamic-api"
:
"0.0.3.7"
,
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.
3
"
,
"ydl-platform"
:
"0.0.39.
5
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.4"
,
...
...
m-im/src/main/java/com/yidianling/im/config/NimApplication.java
View file @
acca90cd
...
...
@@ -4,7 +4,6 @@ import android.app.Application;
import
android.content.Context
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.SDKOptions
;
import
com.netease.nimlib.sdk.auth.LoginInfo
;
import
com.netease.nimlib.sdk.uinfo.model.UserInfo
;
import
com.netease.nimlib.sdk.util.NIMUtil
;
...
...
@@ -14,6 +13,7 @@ import com.yidianling.avchatkit.config.AVChatOptions;
import
com.yidianling.avchatkit.model.ITeamDataProvider
;
import
com.yidianling.avchatkit.model.IUserInfoProvider
;
import
com.yidianling.im.R
;
import
com.yidianling.im.api.bean.IMInitConfigBean
;
import
com.yidianling.im.api.event.AccountChangeEvent
;
import
com.yidianling.im.config.constants.UserPreferences
;
import
com.yidianling.im.helper.ImObserversHelper
;
...
...
@@ -45,13 +45,13 @@ public class NimApplication {
}
public
void
initIm
(
Application
app
,
Class
activity
)
{
initIm
(
app
,
activity
,
n
ew
SDKOptions
()
);
initIm
(
app
,
activity
,
n
ull
);
}
public
void
initIm
(
Application
app
,
Class
activity
,
SDKOptions
sdkOptions
)
{
public
void
initIm
(
Application
app
,
Class
activity
,
IMInitConfigBean
configBean
)
{
IMCache
.
setContext
(
app
);
// 初始化云信SDK
NIMClient
.
init
(
app
,
loginInfo
(),
NimSDKOptionConfig
.
prepareSDKOptions
(
app
,
activity
,
sdkOptions
));
NIMClient
.
init
(
app
,
loginInfo
(),
NimSDKOptionConfig
.
prepareSDKOptions
(
app
,
activity
,
configBean
));
// 以下逻辑只在主进程初始化时执行
if
(
NIMUtil
.
isMainProcess
(
app
))
{
...
...
m-im/src/main/java/com/yidianling/im/config/NimSDKOptionConfig.java
View file @
acca90cd
...
...
@@ -14,6 +14,7 @@ import com.ydl.ydlcommon.base.BaseApp;
import
com.ydl.ydlcommon.base.config.YDLConstants
;
import
com.ydl.ydlcommon.utils.YDLCacheUtils
;
import
com.yidianling.im.R
;
import
com.yidianling.im.api.bean.IMInitConfigBean
;
import
com.yidianling.im.config.constants.UserPreferences
;
import
com.yidianling.im.config.provider.CustomUserInfoProvider
;
import
com.yidianling.im.preference.IMCache
;
...
...
@@ -30,39 +31,14 @@ import java.io.IOException;
class
NimSDKOptionConfig
{
static
SDKOptions
prepareSDKOptions
(
Context
context
,
Class
activity
,
SDKOptions
options
)
{
static
SDKOptions
prepareSDKOptions
(
Context
context
,
Class
activity
,
IMInitConfigBean
configBean
)
{
SDKOptions
options
=
new
SDKOptions
();
//线上环境关闭
if
(
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppDebug
())
{
//配置检查
options
.
checkManifestConfig
=
true
;
}
if
(
TextUtils
.
isEmpty
(
options
.
appKey
))
{
//key配置---逻辑更改:修复切换环境功能
if
(
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppDebug
())
{
String
appEnv
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppEnv
();
//debug包根据url判断使用正式或者测试key
String
cacheAppEnv
=
YDLCacheUtils
.
Companion
.
getCacheApi
();
//这边不能加BuildConfig.DEBUG,因为发布了aar之后,必定为release,导致切换云信的环境失败
if
(!
TextUtils
.
isEmpty
(
cacheAppEnv
))
{
if
(
YDLConstants
.
ENV_TEST
.
equals
(
cacheAppEnv
))
{
options
.
appKey
=
"9a8cefe97b7690537fc1334091af9208"
;
}
else
{
options
.
appKey
=
"4e258ba5cdf489fa188274ebf0fb5669"
;
}
}
else
{
if
(
YDLConstants
.
ENV_TEST
.
equals
(
appEnv
)||
YDLConstants
.
ENV_AUTO_TEST
.
equals
(
appEnv
))
{
options
.
appKey
=
"9a8cefe97b7690537fc1334091af9208"
;
}
else
{
options
.
appKey
=
"4e258ba5cdf489fa188274ebf0fb5669"
;
}
}
}
else
{
//release包始终使用正式key
options
.
appKey
=
"4e258ba5cdf489fa188274ebf0fb5669"
;
}
}
options
.
appKey
=
getIMAppKey
(
configBean
);
// 如果将新消息通知提醒托管给SDK完成,需要添加以下配置。
initStatusBarNotificationConfig
(
context
,
options
,
activity
);
...
...
@@ -103,12 +79,12 @@ class NimSDKOptionConfig {
// 打开消息撤回未读数-1的开关
options
.
shouldConsiderRevokedMessageUnreadCount
=
true
;
if
(
options
.
mixPushConfig
==
null
)
{
options
.
mixPushConfig
=
buildMixPushConfig
();
}
options
.
mixPushConfig
=
buildMixPushConfig
(
configBean
);
return
options
;
}
/**
* 配置 APP 保存图片/语音/文件/log等数据的目录
* 这里示例用SD卡的应用扩展存储目录
...
...
@@ -198,42 +174,105 @@ class NimSDKOptionConfig {
}
};
private
static
MixPushConfig
buildMixPushConfig
()
{
private
static
String
getIMAppKey
(
IMInitConfigBean
configBean
)
{
String
debugKey
=
"9a8cefe97b7690537fc1334091af9208"
;
String
releaseKey
=
"4e258ba5cdf489fa188274ebf0fb5669"
;
String
finalKey
=
""
;
if
(
configBean
!=
null
&&!
TextUtils
.
isEmpty
(
configBean
.
debugAppKey
)&&!
TextUtils
.
isEmpty
(
configBean
.
releaseAppKey
))
{
debugKey
=
configBean
.
debugAppKey
;
releaseKey
=
configBean
.
releaseAppKey
;
}
//key配置---逻辑更改:修复切换环境功能
if
(
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppDebug
())
{
String
appEnv
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppEnv
();
//debug包根据url判断使用正式或者测试key
String
cacheAppEnv
=
YDLCacheUtils
.
Companion
.
getCacheApi
();
if
(!
TextUtils
.
isEmpty
(
cacheAppEnv
))
{
appEnv
=
cacheAppEnv
;
}
if
(
YDLConstants
.
ENV_TEST
.
equals
(
appEnv
)||
YDLConstants
.
ENV_AUTO_TEST
.
equals
(
appEnv
))
{
finalKey
=
debugKey
;
}
else
{
finalKey
=
releaseKey
;
}
}
else
{
//release包始终使用正式key
finalKey
=
releaseKey
;
}
return
finalKey
;
}
private
static
MixPushConfig
buildMixPushConfig
(
IMInitConfigBean
configBean
)
{
// 第三方推送配置
MixPushConfig
config
=
new
MixPushConfig
();
String
appFrom
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppFrom
();
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
))
{
// 小米推送
config
.
xmAppId
=
"2882303761517432980"
;
config
.
xmAppKey
=
"5241743243980"
;
config
.
xmCertificateName
=
"ydlUser"
;
// 华为推送
config
.
hwCertificateName
=
"ydlUserHw"
;
//OPPO 推送
config
.
oppoAppId
=
"3245516"
;
config
.
oppoAppKey
=
"afk71f35VogGw0w0wKsookksc"
;
config
.
oppoAppSercet
=
"691184F044acA7a6851F578451f67616"
;
config
.
oppoCertificateName
=
"ydlUserOPPO"
;
//VIVO 推送
config
.
vivoCertificateName
=
"ydlUserVIVO"
;
}
else
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
appFrom
))
{
if
(
configBean
!=
null
&&
!
TextUtils
.
isEmpty
(
configBean
.
hwCertificateName
))
{
// 小米推送
config
.
xmAppId
=
"2882303761517549919"
;
config
.
xmAppKey
=
"5111754949919"
;
config
.
xmCertificateName
=
"ydlXLZXXM"
;
config
.
xmAppId
=
splitString
(
configBean
.
xmAppId
);
config
.
xmAppKey
=
splitString
(
configBean
.
xmAppKey
);
config
.
xmCertificateName
=
splitString
(
configBean
.
xmCertificateName
);
//魅族
config
.
mzAppId
=
splitString
(
configBean
.
mzAppId
);
config
.
mzAppKey
=
splitString
(
configBean
.
mzAppKey
);
config
.
mzCertificateName
=
splitString
(
configBean
.
mzCertificateName
);
// 华为推送
config
.
hwCertificateName
=
"ydlXLZX"
;
config
.
hwCertificateName
=
splitString
(
configBean
.
hwCertificateName
)
;
//OPPO 推送
config
.
oppoAppId
=
"3601521"
;
config
.
oppoAppKey
=
"c500cJ5mzvSow848048gOsG4G"
;
config
.
oppoAppSercet
=
"F13EbCf4380b683Fb0e316336eeC9Deb"
;
config
.
oppoCertificateName
=
"ydlXLZXOPPO"
;
config
.
oppoAppId
=
splitString
(
configBean
.
oppoAppId
)
;
config
.
oppoAppKey
=
splitString
(
configBean
.
oppoAppKey
)
;
config
.
oppoAppSercet
=
splitString
(
configBean
.
oppoAppSercet
)
;
config
.
oppoCertificateName
=
splitString
(
configBean
.
oppoCertificateName
)
;
//VIVO 推送
config
.
vivoCertificateName
=
"ydlXLZXVIVO"
;
config
.
vivoCertificateName
=
splitString
(
configBean
.
vivoCertificateName
);
}
else
{
String
appFrom
=
BaseApp
.
Companion
.
getInstance
().
getGlobalConfig
().
getAppFrom
();
if
(
YDLConstants
.
FROM_YDL
.
equals
(
appFrom
))
{
// 小米推送
config
.
xmAppId
=
"2882303761517432980"
;
config
.
xmAppKey
=
"5241743243980"
;
config
.
xmCertificateName
=
"ydlUser"
;
// 华为推送
config
.
hwCertificateName
=
"ydlUserHw"
;
//OPPO 推送
config
.
oppoAppId
=
"3245516"
;
config
.
oppoAppKey
=
"afk71f35VogGw0w0wKsookksc"
;
config
.
oppoAppSercet
=
"691184F044acA7a6851F578451f67616"
;
config
.
oppoCertificateName
=
"ydlUserOPPO"
;
//VIVO 推送
config
.
vivoCertificateName
=
"ydlUserVIVO"
;
}
else
if
(
YDLConstants
.
FROM_XLZX
.
equals
(
appFrom
))
{
// 小米推送
config
.
xmAppId
=
"2882303761517549919"
;
config
.
xmAppKey
=
"5111754949919"
;
config
.
xmCertificateName
=
"ydlXLZXXM"
;
// 华为推送
config
.
hwCertificateName
=
"ydlXLZX"
;
//OPPO 推送
config
.
oppoAppId
=
"3601521"
;
config
.
oppoAppKey
=
"c500cJ5mzvSow848048gOsG4G"
;
config
.
oppoAppSercet
=
"F13EbCf4380b683Fb0e316336eeC9Deb"
;
config
.
oppoCertificateName
=
"ydlXLZXOPPO"
;
//VIVO 推送
config
.
vivoCertificateName
=
"ydlXLZXVIVO"
;
}
}
return
config
;
}
private
static
String
splitString
(
String
string
)
{
if
(
string
.
contains
(
"-"
))
{
string
=
string
.
substring
(
string
.
lastIndexOf
(
"-"
)+
1
);
}
return
string
;
}
}
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
View file @
acca90cd
...
...
@@ -14,14 +14,13 @@ import com.netease.nimlib.sdk.auth.LoginInfo
import
com.netease.nimlib.sdk.msg.MessageBuilder
import
com.netease.nimlib.sdk.msg.MsgService
import
com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
import
com.ydl.webview.NewH5Activity
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.router.YdlCommonOut
import
com.ydl.ydlcommon.utils.StringUtils
import
com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import
com.yidianling.avchatkit.common.util.NetworkUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.R
import
com.yidianling.im.api.bean.IMInitConfigBean
import
com.yidianling.im.api.bean.IMLoginInfo
import
com.yidianling.im.api.bean.IMRequestCallback
import
com.yidianling.im.api.listener.ApiStringResponseCallback
...
...
@@ -366,6 +365,14 @@ class IMServiceImpl : IImService {
NimApplication
.
getInstance
().
initIm
(
app
,
activity
)
}
override
fun
initIm
(
app
:
Application
,
activity
:
Class
<
out
Activity
>,
imInitBean
:
IMInitConfigBean
)
{
NimApplication
.
getInstance
().
initIm
(
app
,
activity
,
imInitBean
)
}
override
fun
isWifiOr3G
(
activity
:
Activity
):
Boolean
{
return
NetworkUtil
.
isWifiOr3G
(
activity
)
}
...
...
m-im/src/main/modular_api/com/yidianling/im/api/bean/IMInitConfigBean.java
0 → 100644
View file @
acca90cd
package
com
.
yidianling
.
im
.
api
.
bean
;
/**
* Created by haorui on 2020/3/6.
* Des:
*/
public
class
IMInitConfigBean
{
/**
* 测试环境AppKey
*/
public
String
debugAppKey
;
/**
* 正式环境AppKey
*/
public
String
releaseAppKey
;
/**
* 小米推送 appId
*/
public
String
xmAppId
;
/**
* 小米推送 appKey
*/
public
String
xmAppKey
;
/**
* 小米推送证书,请在云信管理后台申请
*/
public
String
xmCertificateName
;
/**
* 华为推送 appId 请在 AndroidManifest.xml 文件中配置
* 华为推送证书,请在云信管理后台申请
*/
public
String
hwCertificateName
;
/**
* 魅族推送 appId
*/
public
String
mzAppId
;
/**
* 魅族推送 appKey
*/
public
String
mzAppKey
;
/**
* 魅族推送证书,请在云信管理后台申请
*/
public
String
mzCertificateName
;
/**
* FCM 推送证书,请在云信管理后台申请
* 海外客户使用
*/
public
String
fcmCertificateName
;
/**
* VIVO推送 appId apiKey请在 AndroidManifest.xml 文件中配置
* VIVO推送证书,请在云信管理后台申请
*/
public
String
vivoCertificateName
;
/**
* oppo 推送appId
*/
public
String
oppoAppId
;
/**
* oppo 推送appKey
*/
public
String
oppoAppKey
;
/**
* oppo 推送AppSecret
*/
public
String
oppoAppSercet
;
/**
* OPPO推送证书,请在云信管理后台申请
*/
public
String
oppoCertificateName
;
}
m-im/src/main/modular_api/com/yidianling/im/api/service/IImService.kt
View file @
acca90cd
...
...
@@ -5,6 +5,7 @@ import android.app.Application
import
android.content.Context
import
android.support.v4.app.Fragment
import
com.alibaba.android.arouter.facade.template.IProvider
import
com.yidianling.im.api.bean.IMInitConfigBean
import
com.yidianling.im.api.bean.IMLoginInfo
import
com.yidianling.im.api.bean.IMRequestCallback
import
com.yidianling.im.api.listener.ApiStringResponseCallback
...
...
@@ -123,5 +124,7 @@ interface IImService : IProvider {
fun
initIm
(
app
:
Application
,
activity
:
Class
<
out
Activity
>)
fun
initIm
(
app
:
Application
,
activity
:
Class
<
out
Activity
>,
imInitBean
:
IMInitConfigBean
)
fun
isWifiOr3G
(
activity
:
Activity
):
Boolean
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment