Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
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
bp
ShenghuoquanBusiness
Commits
8bb3ee7e
Commit
8bb3ee7e
authored
Jul 30, 2021
by
chengkun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入华为推送代码文件
parent
56c998ca
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
18 deletions
+106
-18
AndroidManifest.xml
Components/BPush/src/main/AndroidManifest.xml
+9
-1
HuaWeiPushPolicy.kt
...an/shenghuoquan/bpush/push/huaweipush/HuaWeiPushPolicy.kt
+5
-1
HuaweiPushGetDataService.java
...ush/push/huaweipush/service/HuaweiPushGetDataService.java
+81
-0
build.gradle
app/build.gradle
+1
-0
build.gradle
build.gradle
+8
-15
config.gradle
config/config.gradle
+2
-1
No files found.
Components/BPush/src/main/AndroidManifest.xml
View file @
8bb3ee7e
...
@@ -15,6 +15,10 @@
...
@@ -15,6 +15,10 @@
android:protectionLevel=
"signature"
/>
android:protectionLevel=
"signature"
/>
<uses-permission
android:name=
"com.shenghuoquan.business.permission.MIPUSH_RECEIVE"
/>
<uses-permission
android:name=
"com.shenghuoquan.business.permission.MIPUSH_RECEIVE"
/>
<application>
<application>
<meta-data
android:name=
"com.huawei.hms.client.channel.androidMarket"
android:value=
"false"
/>
<!--小米推送服务-->
<!--小米推送服务-->
<receiver
<receiver
android:name=
".push.mipush.receiver.MiPushReceiver"
android:name=
".push.mipush.receiver.MiPushReceiver"
...
@@ -86,5 +90,9 @@
...
@@ -86,5 +90,9 @@
</intent-filter>
</intent-filter>
</service>
<!--兼容Q版本-->
</service>
<!--兼容Q版本-->
</application>
</application>
<queries>
<intent>
<action
android:name=
"com.huawei.hms.core.aidlservice"
/>
</intent>
</queries>
</manifest>
</manifest>
\ No newline at end of file
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/huaweipush/HuaWeiPushPolicy.kt
View file @
8bb3ee7e
package
com.yidian.shenghuoquan.bpush.push.huaweipush
package
com.yidian.shenghuoquan.bpush.push.huaweipush
import
com.huawei.agconnect.config.AGConnectServicesConfig
import
com.huawei.hms.aaid.HmsInstanceId
import
com.yidian.shenghuoquan.bpush.app.BPushApplication
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
HuaWeiPushPolicy
:
PushPolicy
()
{
class
HuaWeiPushPolicy
:
PushPolicy
()
{
override
fun
initPushSdk
()
{
override
fun
initPushSdk
()
{
TODO
(
"Not yet implemented"
)
val
appId
=
AGConnectServicesConfig
.
fromContext
(
BPushApplication
.
context
).
getString
(
"client/app_id"
)
val
token
=
HmsInstanceId
.
getInstance
(
BPushApplication
.
context
).
getToken
(
appId
,
"HCM"
)
}
}
override
fun
pubMessage
(
message
:
String
)
{
override
fun
pubMessage
(
message
:
String
)
{
...
...
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/huaweipush/service/HuaweiPushGetDataService.java
0 → 100644
View file @
8bb3ee7e
package
com
.
yidian
.
shenghuoquan
.
bpush
.
push
.
huaweipush
.
service
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
com.huawei.hms.push.HmsMessageService
;
import
com.huawei.hms.push.RemoteMessage
;
import
java.util.Arrays
;
public
class
HuaweiPushGetDataService
extends
HmsMessageService
{
private
static
final
String
TAG
=
"PushGetDataService"
;
// This method callback must be completed in 10 seconds. Otherwise, you need to start a new Job for callback processing.
// extends HmsMessageService super class
@Override
public
void
onNewToken
(
String
token
)
{
Log
.
i
(
TAG
,
"received refresh token:"
+
token
);
// send the token to your app server.
if
(!
TextUtils
.
isEmpty
(
token
))
{
refreshedTokenToServer
(
token
);
}
}
@Override
public
void
onMessageReceived
(
RemoteMessage
message
)
{
Log
.
i
(
TAG
,
"onMessageReceived is called"
);
if
(
message
==
null
)
{
Log
.
e
(
TAG
,
"Received message entity is null!"
);
return
;
}
Log
.
i
(
TAG
,
"getCollapseKey: "
+
message
.
getCollapseKey
()
+
"\n getData: "
+
message
.
getData
()
+
"\n getFrom: "
+
message
.
getFrom
()
+
"\n getTo: "
+
message
.
getTo
()
+
"\n getMessageId: "
+
message
.
getMessageId
()
+
"\n getSendTime: "
+
message
.
getSentTime
()
+
"\n getDataMap: "
+
message
.
getDataOfMap
()
+
"\n getMessageType: "
+
message
.
getMessageType
()
+
"\n getTtl: "
+
message
.
getTtl
()
+
"\n getToken: "
+
message
.
getToken
());
RemoteMessage
.
Notification
notification
=
message
.
getNotification
();
if
(
notification
!=
null
)
{
Log
.
i
(
TAG
,
"\n getImageUrl: "
+
notification
.
getImageUrl
()
+
"\n getTitle: "
+
notification
.
getTitle
()
+
"\n getTitleLocalizationKey: "
+
notification
.
getTitleLocalizationKey
()
+
"\n getTitleLocalizationArgs: "
+
Arrays
.
toString
(
notification
.
getTitleLocalizationArgs
())
+
"\n getBody: "
+
notification
.
getBody
()
+
"\n getBodyLocalizationKey: "
+
notification
.
getBodyLocalizationKey
()
+
"\n getBodyLocalizationArgs: "
+
Arrays
.
toString
(
notification
.
getBodyLocalizationArgs
())
+
"\n getIcon: "
+
notification
.
getIcon
()
+
"\n getSound: "
+
notification
.
getSound
()
+
"\n getTag: "
+
notification
.
getTag
()
+
"\n getColor: "
+
notification
.
getColor
()
+
"\n getClickAction: "
+
notification
.
getClickAction
()
+
"\n getChannelId: "
+
notification
.
getChannelId
()
+
"\n getLink: "
+
notification
.
getLink
()
+
"\n getNotifyId: "
+
notification
.
getNotifyId
());
}
Boolean
judgeWhetherIn10s
=
false
;
// If the messages are not processed in 10 seconds, the app needs to use WorkManager for processing.
if
(
judgeWhetherIn10s
)
{
startWorkManagerJob
(
message
);
}
else
{
// Process message within 10s
processWithin10s
(
message
);
}
}
private
void
startWorkManagerJob
(
RemoteMessage
message
)
{
Log
.
d
(
TAG
,
"Start new job processing."
);
}
private
void
processWithin10s
(
RemoteMessage
message
)
{
Log
.
d
(
TAG
,
"Processing now."
);
}
private
void
refreshedTokenToServer
(
String
token
)
{
Log
.
i
(
TAG
,
"sending token to server. token:"
+
token
);
}
}
app/build.gradle
View file @
8bb3ee7e
...
@@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
...
@@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
apply
plugin:
'yac-engine'
apply
plugin:
'yac-engine'
apply
plugin:
'kotlin-kapt'
apply
plugin:
'kotlin-kapt'
apply
plugin:
'kotlin-parcelize'
apply
plugin:
'kotlin-parcelize'
apply
plugin:
'com.huawei.agconnect'
android
{
android
{
compileSdkVersion
build_versions
.
compileSdkVersion
compileSdkVersion
build_versions
.
compileSdkVersion
...
...
build.gradle
View file @
8bb3ee7e
...
@@ -5,20 +5,19 @@ buildscript {
...
@@ -5,20 +5,19 @@ buildscript {
addRepos
(
repositories
)
addRepos
(
repositories
)
ext
.
kotlin_version
=
build_versions
.
kotlin_version
ext
.
kotlin_version
=
build_versions
.
kotlin_version
repositories
{
repositories
{
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/public/'
}
maven
{
url
"https://jitpack.io"
}
// 友盟 SDK maven仓库地址
maven
{
url
'https://repo1.maven.org/maven2/'
}
// 新浪微博官方分享SDK
maven
{
url
"https://dl.bintray.com/thelasterstar/maven/"
}
google
()
google
()
mavenCentral
()
mavenCentral
()
jcenter
()
jcenter
()
// 配置HMS Core SDK的Maven仓地址。
maven
{
url
'https://developer.huawei.com/repo/'
}
}
}
dependencies
{
dependencies
{
classpath
deps
.
gradle
.
plugin
classpath
deps
.
gradle
.
plugin
classpath
deps
.
kotlin
.
plugin
classpath
deps
.
kotlin
.
plugin
classpath
deps
.
yac
.
engine
classpath
deps
.
yac
.
engine
// 增加agcp插件配置。
classpath
'com.huawei.agconnect:agcp:1.4.2.300'
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// in the individual module build.gradle files
...
@@ -27,18 +26,12 @@ buildscript {
...
@@ -27,18 +26,12 @@ buildscript {
allprojects
{
allprojects
{
repositories
{
repositories
{
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/repository/public/'
}
maven
{
url
"https://www.jitpack.io"
}
// 友盟 SDK maven仓库地址
maven
{
url
'https://repo1.maven.org/maven2/'
}
// 新浪微博官方分享SDK
maven
{
url
"https://dl.bintray.com/thelasterstar/maven/"
}
maven
{
url
"http://dailybuild2.yidian-inc.com:8088/repository/maven-public/"
}
// ping++ maven仓库地址
maven
{
url
"https://dl.bintray.com/pingxx/maven"
}
google
()
google
()
mavenCentral
()
mavenCentral
()
jcenter
()
jcenter
()
// 配置HMS Core SDK的Maven仓地址。
maven
{
url
'https://developer.huawei.com/repo/'
}
}
}
addRepos
(
repositories
)
addRepos
(
repositories
)
}
}
...
...
config/config.gradle
View file @
8bb3ee7e
...
@@ -140,7 +140,8 @@ ext.dependencies = [
...
@@ -140,7 +140,8 @@ ext.dependencies = [
// PictureSelector2.0 https://github.com/LuckSiege/PictureSelector
// PictureSelector2.0 https://github.com/LuckSiege/PictureSelector
'io.github.lucksiege:pictureselector:v2.7.3-rc05'
,
'io.github.lucksiege:pictureselector:v2.7.3-rc05'
,
// Compressor https://github.com/zetbaitsu/Compressor
// Compressor https://github.com/zetbaitsu/Compressor
'id.zelory:compressor:3.0.1'
'id.zelory:compressor:3.0.1'
,
'com.huawei.hms:push:5.3.0.304'
],
],
other
:
[
other
:
[
':CommonLib:BCommon'
':CommonLib:BCommon'
...
...
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