Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
F
flutter-push
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
flutter-push
Commits
d1726609
提交
d1726609
authored
12月 16, 2022
作者:
张国庆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改推送 插件
上级
66dfeb53
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
211 行增加
和
130 行删除
+211
-130
build.gradle
android/build.gradle
+1
-0
PopupPushActivity.kt
.../src/main/kotlin/com/jarvanmo/rammus/PopupPushActivity.kt
+5
-3
RammusPlugin.kt
android/src/main/kotlin/com/jarvanmo/rammus/RammusPlugin.kt
+176
-105
RammusPushIntentService.kt
...ain/kotlin/com/jarvanmo/rammus/RammusPushIntentService.kt
+9
-7
build.gradle
example/android/app/build.gradle
+1
-0
AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+1
-9
MyApplication.kt
.../main/kotlin/com/jarvanmo/rammus_example/MyApplication.kt
+0
-3
main.dart
example/lib/main.dart
+17
-2
pubspec.yaml
pubspec.yaml
+1
-1
没有找到文件。
android/build.gradle
浏览文件 @
d1726609
...
@@ -61,4 +61,5 @@ dependencies {
...
@@ -61,4 +61,5 @@ dependencies {
implementation
"com.aliyun.ams:alicloud-android-third-push-oppo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-oppo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-vivo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-vivo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-honor:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-honor:$push_version"
implementation
"com.blankj:utilcodex:1.31.1"
}
}
android/src/main/kotlin/com/jarvanmo/rammus/PopupPushActivity.kt
浏览文件 @
d1726609
...
@@ -2,22 +2,24 @@ package com.jarvanmo.rammus
...
@@ -2,22 +2,24 @@ package com.jarvanmo.rammus
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Handler
import
android.os.Handler
import
android.os.Looper
import
android.os.PersistableBundle
import
android.os.PersistableBundle
import
android.util.Log
import
android.util.Log
import
com.alibaba.sdk.android.push.AndroidPopupActivity
import
com.alibaba.sdk.android.push.AndroidPopupActivity
import
com.blankj.utilcode.util.LogUtils
import
org.json.JSONObject
import
org.json.JSONObject
class
PopupPushActivity
:
AndroidPopupActivity
()
{
class
PopupPushActivity
:
AndroidPopupActivity
()
{
private
val
handler
=
Handler
()
private
val
handler
=
Handler
(
Looper
.
getMainLooper
()
)
override
fun
onSysNoticeOpened
(
title
:
String
,
summary
:
String
,
extras
:
MutableMap
<
String
,
String
>)
{
override
fun
onSysNoticeOpened
(
title
:
String
,
summary
:
String
,
extras
:
MutableMap
<
String
,
String
>)
{
Log
.
d
(
"PopupPushActivity"
,
"onSysNoticeOpened, title: $title, content: $summary, extMap
: $extras"
)
Log
Utils
.
d
(
"onSysNoticeOpened title is $title, summary is $summary, extras
: $extras"
)
startActivity
(
packageManager
.
getLaunchIntentForPackage
(
packageName
))
startActivity
(
packageManager
.
getLaunchIntentForPackage
(
packageName
))
var
jsonExtras
=
JSONObject
()
var
jsonExtras
=
JSONObject
()
for
(
key
in
extras
.
keys
){
for
(
key
in
extras
.
keys
){
jsonExtras
.
putOpt
(
key
,
extras
[
key
])
jsonExtras
.
putOpt
(
key
,
extras
[
key
])
}
}
Log
.
d
(
"PopupPushActivity"
,
"onSysNoticeOpened extras: ${jsonExtras.toString()}"
)
Log
Utils
.
d
(
"onSysNoticeOpened extras: ${jsonExtras.toString()}"
)
handler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationOpened"
,
mapOf
(
handler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationOpened"
,
mapOf
(
"title"
to
title
,
"title"
to
title
,
"summary"
to
summary
,
"summary"
to
summary
,
...
...
android/src/main/kotlin/com/jarvanmo/rammus/RammusPlugin.kt
浏览文件 @
d1726609
...
@@ -11,12 +11,12 @@ import android.content.pm.PackageManager
...
@@ -11,12 +11,12 @@ import android.content.pm.PackageManager
import
android.os.Build
import
android.os.Build
import
android.os.Handler
import
android.os.Handler
import
android.os.Looper
import
android.os.Looper
import
android.util.Log
import
com.alibaba.sdk.android.push.CommonCallback
import
com.alibaba.sdk.android.push.CommonCallback
import
com.alibaba.sdk.android.push.HonorRegister
import
com.alibaba.sdk.android.push.HonorRegister
import
com.alibaba.sdk.android.push.huawei.HuaWeiRegister
import
com.alibaba.sdk.android.push.huawei.HuaWeiRegister
import
com.alibaba.sdk.android.push.noonesdk.PushServiceFactory
import
com.alibaba.sdk.android.push.noonesdk.PushServiceFactory
import
com.alibaba.sdk.android.push.register.*
import
com.alibaba.sdk.android.push.register.*
import
com.blankj.utilcode.util.LogUtils
import
io.flutter.embedding.engine.plugins.FlutterPlugin
import
io.flutter.embedding.engine.plugins.FlutterPlugin
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.MethodChannel
...
@@ -24,27 +24,21 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
...
@@ -24,27 +24,21 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import
io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.MethodChannel.Result
class
RammusPlugin
:
FlutterPlugin
,
MethodCallHandler
{
class
RammusPlugin
:
FlutterPlugin
,
MethodCallHandler
{
companion
object
{
companion
object
{
private
const
val
TAG
=
"RammusPlugin"
private
val
inHandler
=
Handler
(
Looper
.
getMainLooper
())
private
val
inHandler
=
Handler
(
Looper
.
getMainLooper
())
private
var
gottenApplication
:
Application
?
=
null
lateinit
var
gottenApplication
:
Context
@JvmStatic
fun
initPushService
(
application
:
Application
){
gottenApplication
=
application
PushServiceFactory
.
init
(
application
.
applicationContext
)
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
setPushIntentService
(
RammusPushIntentService
::
class
.
java
)
}
}
}
private
lateinit
var
channel
:
MethodChannel
private
lateinit
var
channel
:
MethodChannel
override
fun
onMethodCall
(
call
:
MethodCall
,
result
:
Result
)
{
override
fun
onMethodCall
(
call
:
MethodCall
,
result
:
Result
)
{
LogUtils
.
d
(
call
.
method
)
when
(
call
.
method
)
{
when
(
call
.
method
)
{
"register"
->
register
()
"register"
->
register
()
"initPushService"
->
initPushService
()
"deviceId"
->
result
.
success
(
PushServiceFactory
.
getCloudPushService
().
deviceId
)
"deviceId"
->
result
.
success
(
PushServiceFactory
.
getCloudPushService
().
deviceId
)
"turnOnPushChannel"
->
turnOnPushChannel
(
result
)
"turnOnPushChannel"
->
turnOnPushChannel
(
result
)
"turnOffPushChannel"
->
turnOffPushChannel
(
result
)
"turnOffPushChannel"
->
turnOffPushChannel
(
result
)
...
@@ -60,71 +54,82 @@ class RammusPlugin :
...
@@ -60,71 +54,82 @@ class RammusPlugin :
"setupNotificationManager"
->
setupNotificationManager
(
call
,
result
)
"setupNotificationManager"
->
setupNotificationManager
(
call
,
result
)
"bindPhoneNumber"
->
bindPhoneNumber
(
call
,
result
)
"bindPhoneNumber"
->
bindPhoneNumber
(
call
,
result
)
"unbindPhoneNumber"
->
unbindPhoneNumber
(
result
)
"unbindPhoneNumber"
->
unbindPhoneNumber
(
result
)
"applicationBadgeNumberClean"
->
setApplicationBadgeNumber
(
call
)
"applicationBadgeNumberClean"
->
setApplicationBadgeNumber
(
call
)
else
->
result
.
notImplemented
()
else
->
result
.
notImplemented
()
}
}
}
}
private
fun
register
()
{
private
fun
register
()
{
if
(
gottenApplication
==
null
)
{
Log
.
w
(
TAG
,
"注册推送服务失败,请检查是否在运行本语句前执行了`RammusPlugin.initPushService`."
)
return
}
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
register
(
gottenApplication
,
object
:
CommonCallback
{
pushService
.
register
(
gottenApplication
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
inHandler
.
postDelayed
({
inHandler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"initCloudChannelResult"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"initCloudChannelResult"
,
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
},
2000
)
},
2000
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
inHandler
.
postDelayed
({
inHandler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"initCloudChannelResult"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"initCloudChannelResult"
,
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
},
2000
)
},
2000
)
}
}
})
})
val
appInfo
=
gottenApplication
!!
.
packageManager
val
appInfo
=
gottenApplication
.
packageManager
.
getApplicationInfo
(
gottenApplication
!!
.
packageName
,
PackageManager
.
GET_META_DATA
)
.
getApplicationInfo
(
gottenApplication
.
packageName
,
PackageManager
.
GET_META_DATA
)
val
xiaomiAppId
=
appInfo
.
metaData
.
getString
(
"com.xiaomi.push.client.app_id"
)
val
xiaomiAppId
=
appInfo
.
metaData
.
getString
(
"com.xiaomi.push.client.app_id"
)
val
xiaomiAppKey
=
appInfo
.
metaData
.
getString
(
"com.xiaomi.push.client.app_key"
)
val
xiaomiAppKey
=
appInfo
.
metaData
.
getString
(
"com.xiaomi.push.client.app_key"
)
if
((
xiaomiAppId
!=
null
&&
xiaomiAppId
.
isNotBlank
())
if
((
xiaomiAppId
!=
null
&&
xiaomiAppId
.
isNotBlank
())
&&
(
xiaomiAppKey
!=
null
&&
xiaomiAppKey
.
isNotBlank
())){
&&
(
xiaomiAppKey
!=
null
&&
xiaomiAppKey
.
isNotBlank
())
Log
.
d
(
TAG
,
"正在注册小米推送服务..."
)
)
{
LogUtils
.
d
(
"正在注册小米推送服务..."
)
MiPushRegister
.
register
(
gottenApplication
,
xiaomiAppId
,
xiaomiAppKey
)
MiPushRegister
.
register
(
gottenApplication
,
xiaomiAppId
,
xiaomiAppKey
)
}
}
val
huaweiAppId
=
appInfo
.
metaData
.
getString
(
"com.huawei.hms.client.appid"
)
val
huaweiAppId
=
appInfo
.
metaData
.
getString
(
"com.huawei.hms.client.appid"
)
if
(
huaweiAppId
!=
null
&&
huaweiAppId
.
toString
().
isNotBlank
()){
if
(
huaweiAppId
!=
null
&&
huaweiAppId
.
toString
().
isNotBlank
())
{
Log
.
d
(
TAG
,
"正在注册华为推送服务..."
)
Log
Utils
.
d
(
"正在注册华为推送服务..."
)
HuaWeiRegister
.
register
(
gottenApplication
)
HuaWeiRegister
.
register
(
gottenApplication
as
Application
)
}
}
val
oppoAppKey
=
appInfo
.
metaData
.
getString
(
"com.oppo.push.client.app_key"
)
val
oppoAppKey
=
appInfo
.
metaData
.
getString
(
"com.oppo.push.client.app_key"
)
val
oppoAppSecret
=
appInfo
.
metaData
.
getString
(
"com.oppo.push.client.app_secret"
)
val
oppoAppSecret
=
appInfo
.
metaData
.
getString
(
"com.oppo.push.client.app_secret"
)
if
((
oppoAppKey
!=
null
&&
oppoAppKey
.
isNotBlank
())
if
((
oppoAppKey
!=
null
&&
oppoAppKey
.
isNotBlank
())
&&
(
oppoAppSecret
!=
null
&&
oppoAppSecret
.
isNotBlank
())){
&&
(
oppoAppSecret
!=
null
&&
oppoAppSecret
.
isNotBlank
())
Log
.
d
(
TAG
,
"正在注册Oppo推送服务..."
)
)
{
LogUtils
.
d
(
"正在注册Oppo推送服务..."
)
OppoRegister
.
register
(
gottenApplication
,
oppoAppKey
,
oppoAppSecret
)
OppoRegister
.
register
(
gottenApplication
,
oppoAppKey
,
oppoAppSecret
)
}
}
val
vivoAppId
=
appInfo
.
metaData
.
getString
(
"com.vivo.push.app_id"
)
val
vivoAppId
=
appInfo
.
metaData
.
getString
(
"com.vivo.push.app_id"
)
val
vivoApiKey
=
appInfo
.
metaData
.
getString
(
"com.vivo.push.api_key"
)
val
vivoApiKey
=
appInfo
.
metaData
.
getString
(
"com.vivo.push.api_key"
)
if
((
vivoAppId
!=
null
&&
vivoAppId
.
isNotBlank
())
if
((
vivoAppId
!=
null
&&
vivoAppId
.
isNotBlank
())
&&
(
vivoApiKey
!=
null
&&
vivoApiKey
.
isNotBlank
())){
&&
(
vivoApiKey
!=
null
&&
vivoApiKey
.
isNotBlank
())
Log
.
d
(
TAG
,
"正在注册Vivo推送服务..."
)
)
{
LogUtils
.
d
(
"正在注册vivo推送服务..."
)
VivoRegister
.
register
(
gottenApplication
)
VivoRegister
.
register
(
gottenApplication
)
}
}
val
hihonorId
=
appInfo
.
metaData
.
getString
(
"com.hihonor.push.app_id"
)
val
hihonorId
=
appInfo
.
metaData
.
getString
(
"com.hihonor.push.app_id"
)
if
(
hihonorId
!=
null
&&
hihonorId
.
toString
().
isNotBlank
()){
if
(
hihonorId
!=
null
&&
hihonorId
.
toString
().
isNotBlank
())
{
Log
.
d
(
TAG
,
"正在注册荣耀推送服务..."
)
LogUtils
.
d
(
"正在注册荣耀推送服务..."
)
HonorRegister
.
register
(
gottenApplication
)
HonorRegister
.
register
(
gottenApplication
as
Application
)
}
}
}
private
fun
initPushService
(){
PushServiceFactory
.
init
(
gottenApplication
)
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
setPushIntentService
(
RammusPushIntentService
::
class
.
java
)
LogUtils
.
d
(
"initPushService"
)
}
}
...
@@ -132,19 +137,23 @@ class RammusPlugin :
...
@@ -132,19 +137,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
turnOnPushChannel
(
object
:
CommonCallback
{
pushService
.
turnOnPushChannel
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -153,19 +162,23 @@ class RammusPlugin :
...
@@ -153,19 +162,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
turnOffPushChannel
(
object
:
CommonCallback
{
pushService
.
turnOffPushChannel
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -175,19 +188,23 @@ class RammusPlugin :
...
@@ -175,19 +188,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
checkPushChannelStatus
(
object
:
CommonCallback
{
pushService
.
checkPushChannelStatus
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -197,19 +214,23 @@ class RammusPlugin :
...
@@ -197,19 +214,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
bindAccount
(
call
.
arguments
as
String
?,
object
:
CommonCallback
{
pushService
.
bindAccount
(
call
.
arguments
as
String
?,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -219,19 +240,23 @@ class RammusPlugin :
...
@@ -219,19 +240,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
unbindAccount
(
object
:
CommonCallback
{
pushService
.
unbindAccount
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -243,19 +268,23 @@ class RammusPlugin :
...
@@ -243,19 +268,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
bindPhoneNumber
(
call
.
arguments
as
String
?,
object
:
CommonCallback
{
pushService
.
bindPhoneNumber
(
call
.
arguments
as
String
?,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -265,19 +294,23 @@ class RammusPlugin :
...
@@ -265,19 +294,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
unbindPhoneNumber
(
object
:
CommonCallback
{
pushService
.
unbindPhoneNumber
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -296,19 +329,23 @@ class RammusPlugin :
...
@@ -296,19 +329,23 @@ class RammusPlugin :
pushService
.
bindTag
(
target
,
tags
,
alias
,
object
:
CommonCallback
{
pushService
.
bindTag
(
target
,
tags
,
alias
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -327,19 +364,23 @@ class RammusPlugin :
...
@@ -327,19 +364,23 @@ class RammusPlugin :
pushService
.
unbindTag
(
target
,
tags
,
alias
,
object
:
CommonCallback
{
pushService
.
unbindTag
(
target
,
tags
,
alias
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -349,19 +390,23 @@ class RammusPlugin :
...
@@ -349,19 +390,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
listTags
(
target
,
object
:
CommonCallback
{
pushService
.
listTags
(
target
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -372,19 +417,23 @@ class RammusPlugin :
...
@@ -372,19 +417,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
addAlias
(
alias
,
object
:
CommonCallback
{
pushService
.
addAlias
(
alias
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -394,19 +443,23 @@ class RammusPlugin :
...
@@ -394,19 +443,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
removeAlias
(
alias
,
object
:
CommonCallback
{
pushService
.
removeAlias
(
alias
,
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -415,19 +468,23 @@ class RammusPlugin :
...
@@ -415,19 +468,23 @@ class RammusPlugin :
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
val
pushService
=
PushServiceFactory
.
getCloudPushService
()
pushService
.
listAliases
(
object
:
CommonCallback
{
pushService
.
listAliases
(
object
:
CommonCallback
{
override
fun
onSuccess
(
response
:
String
?)
{
override
fun
onSuccess
(
response
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
true
,
"isSuccessful"
to
true
,
"response"
to
response
"response"
to
response
))
)
)
}
}
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
override
fun
onFailed
(
errorCode
:
String
?,
errorMessage
:
String
?)
{
result
.
success
(
mapOf
(
result
.
success
(
mapOf
(
"isSuccessful"
to
false
,
"isSuccessful"
to
false
,
"errorCode"
to
errorCode
,
"errorCode"
to
errorCode
,
"errorMessage"
to
errorMessage
"errorMessage"
to
errorMessage
))
)
)
}
}
})
})
}
}
...
@@ -436,15 +493,16 @@ class RammusPlugin :
...
@@ -436,15 +493,16 @@ class RammusPlugin :
private
fun
setupNotificationManager
(
call
:
MethodCall
,
result
:
Result
)
{
private
fun
setupNotificationManager
(
call
:
MethodCall
,
result
:
Result
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channels
=
call
.
arguments
as
List
<
Map
<
String
,
Any
?>>
val
channels
=
call
.
arguments
as
List
<
Map
<
String
,
Any
?>>
val
mNotificationManager
=
gottenApplication
?.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
mNotificationManager
=
gottenApplication
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationChannels
=
mutableListOf
<
NotificationChannel
>()
val
notificationChannels
=
mutableListOf
<
NotificationChannel
>()
for
(
channel
in
channels
){
for
(
channel
in
channels
)
{
// 通知渠道的id
// 通知渠道的id
val
id
=
channel
[
"id"
]
?:
gottenApplication
?
.
packageName
val
id
=
channel
[
"id"
]
?:
gottenApplication
.
packageName
// 用户可以看到的通知渠道的名字.
// 用户可以看到的通知渠道的名字.
val
name
=
channel
[
"name"
]
?:
gottenApplication
?
.
packageName
val
name
=
channel
[
"name"
]
?:
gottenApplication
.
packageName
// 用户可以看到的通知渠道的描述
// 用户可以看到的通知渠道的描述
val
description
=
channel
[
"description"
]
?:
gottenApplication
?
.
packageName
val
description
=
channel
[
"description"
]
?:
gottenApplication
.
packageName
val
importance
=
channel
[
"importance"
]
?:
NotificationManager
.
IMPORTANCE_DEFAULT
val
importance
=
channel
[
"importance"
]
?:
NotificationManager
.
IMPORTANCE_DEFAULT
val
mChannel
=
NotificationChannel
(
id
as
String
,
name
as
String
,
importance
as
Int
)
val
mChannel
=
NotificationChannel
(
id
as
String
,
name
as
String
,
importance
as
Int
)
// 配置通知渠道的属性
// 配置通知渠道的属性
...
@@ -453,7 +511,7 @@ class RammusPlugin :
...
@@ -453,7 +511,7 @@ class RammusPlugin :
mChannel
.
enableVibration
(
true
)
mChannel
.
enableVibration
(
true
)
notificationChannels
.
add
(
mChannel
)
notificationChannels
.
add
(
mChannel
)
}
}
if
(
notificationChannels
.
isNotEmpty
()){
if
(
notificationChannels
.
isNotEmpty
())
{
mNotificationManager
.
createNotificationChannels
(
notificationChannels
)
mNotificationManager
.
createNotificationChannels
(
notificationChannels
)
}
}
}
}
...
@@ -461,34 +519,47 @@ class RammusPlugin :
...
@@ -461,34 +519,47 @@ class RammusPlugin :
}
}
//设置android角标
//设置android角标
private
fun
setApplicationBadgeNumber
(
call
:
MethodCall
){
private
fun
setApplicationBadgeNumber
(
call
:
MethodCall
)
{
val
appInfo
=
gottenApplication
!!
.
packageManager
val
appInfo
=
gottenApplication
.
packageManager
.
getApplicationInfo
(
gottenApplication
!!
.
packageName
,
PackageManager
.
GET_META_DATA
)
.
getApplicationInfo
(
gottenApplication
.
packageName
,
PackageManager
.
GET_META_DATA
)
val
num
=
call
.
argument
(
"num"
)
as
Int
?
?:
0
val
num
=
call
.
argument
(
"num"
)
as
Int
?
?:
0
setHuaWeiApplicationBadgeNumber
(
num
,
appInfo
)
setHuaWeiApplicationBadgeNumber
(
num
,
appInfo
)
}
}
//清理华为角标 https://developer.huawei.com/consumer/cn/doc/development/Corner-Guides/30802
//清理华为角标 https://developer.huawei.com/consumer/cn/doc/development/Corner-Guides/30802
private
fun
setHuaWeiApplicationBadgeNumber
(
num
:
Int
,
appInfo
:
ApplicationInfo
)
{
private
fun
setHuaWeiApplicationBadgeNumber
(
num
:
Int
,
appInfo
:
ApplicationInfo
)
{
val
huaweiAppId
=
appInfo
.
metaData
.
getString
(
"com.huawei.hms.client.appid"
)
val
huaweiAppId
=
appInfo
.
metaData
.
getString
(
"com.huawei.hms.client.appid"
)
if
(
huaweiAppId
!=
null
&&
huaweiAppId
.
toString
().
isNotBlank
()){
if
(
huaweiAppId
!=
null
&&
huaweiAppId
.
toString
().
isNotBlank
())
{
try
{
try
{
val
bundle
=
Bundle
()
val
bundle
=
Bundle
()
bundle
.
putString
(
"package"
,
gottenApplication
?.
packageName
)
// com.test.badge is your package name
bundle
.
putString
(
bundle
.
putString
(
"class"
,
gottenApplication
?.
packageName
+
".MainActivity"
)
// com.test. badge.MainActivity is your apk main activity
"package"
,
gottenApplication
.
packageName
)
// com.test.badge is your package name
bundle
.
putString
(
"class"
,
gottenApplication
.
packageName
+
".MainActivity"
)
// com.test. badge.MainActivity is your apk main activity
bundle
.
putInt
(
"badgenumber"
,
num
)
bundle
.
putInt
(
"badgenumber"
,
num
)
gottenApplication
!!
.
contentResolver
.
call
(
Uri
.
parse
(
"content://com.huawei.android.launcher.settings/badge/"
),
"change_badge"
,
null
,
bundle
)
gottenApplication
.
contentResolver
.
call
(
Uri
.
parse
(
"content://com.huawei.android.launcher.settings/badge/"
),
"change_badge"
,
null
,
bundle
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
Log
.
w
(
TAG
,
"setHuaWeiApplicationBadgeNumberClean: 失败"
+
e
.
message
)
Log
Utils
.
w
(
"setHuaWeiApplicationBadgeNumberClean: 失败"
+
e
.
message
)
}
}
}
}
}
}
override
fun
onAttachedToEngine
(
flutterPluginBinding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
override
fun
onAttachedToEngine
(
flutterPluginBinding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
gottenApplication
=
flutterPluginBinding
.
applicationContext
channel
=
MethodChannel
(
flutterPluginBinding
.
binaryMessenger
,
"com.jarvanmo/rammus"
)
channel
=
MethodChannel
(
flutterPluginBinding
.
binaryMessenger
,
"com.jarvanmo/rammus"
)
channel
.
setMethodCallHandler
(
this
)
channel
.
setMethodCallHandler
(
this
)
...
...
android/src/main/kotlin/com/jarvanmo/rammus/RammusPushIntentService.kt
浏览文件 @
d1726609
...
@@ -2,9 +2,11 @@ package com.jarvanmo.rammus
...
@@ -2,9 +2,11 @@ package com.jarvanmo.rammus
import
android.content.Context
import
android.content.Context
import
android.os.Handler
import
android.os.Handler
import
android.os.Looper
import
android.util.Log
import
android.util.Log
import
com.alibaba.sdk.android.push.AliyunMessageIntentService
import
com.alibaba.sdk.android.push.AliyunMessageIntentService
import
com.alibaba.sdk.android.push.notification.CPushMessage
import
com.alibaba.sdk.android.push.notification.CPushMessage
import
com.blankj.utilcode.util.LogUtils
/***
/***
* Created by mo on 2019-06-25
* Created by mo on 2019-06-25
...
@@ -13,10 +15,10 @@ import com.alibaba.sdk.android.push.notification.CPushMessage
...
@@ -13,10 +15,10 @@ import com.alibaba.sdk.android.push.notification.CPushMessage
**/
**/
class
RammusPushIntentService
:
AliyunMessageIntentService
()
{
class
RammusPushIntentService
:
AliyunMessageIntentService
()
{
private
val
handler
=
Handler
()
private
val
handler
=
Handler
(
Looper
.
getMainLooper
()
)
override
fun
onNotificationRemoved
(
context
:
Context
,
messageId
:
String
?)
{
override
fun
onNotificationRemoved
(
context
:
Context
,
messageId
:
String
?)
{
Log
.
d
(
"RammusPushIntentService"
,
"onNotificationRemoved messageId is $messageId"
)
Log
Utils
.
d
(
"onNotificationRemoved messageId is $messageId"
)
handler
.
postDelayed
(
{
handler
.
postDelayed
(
{
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationRemoved"
,
messageId
)
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationRemoved"
,
messageId
)
...
@@ -24,7 +26,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
...
@@ -24,7 +26,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
}
}
override
fun
onNotification
(
context
:
Context
,
title
:
String
?,
summary
:
String
?,
extras
:
MutableMap
<
String
,
String
>?)
{
override
fun
onNotification
(
context
:
Context
,
title
:
String
?,
summary
:
String
?,
extras
:
MutableMap
<
String
,
String
>?)
{
Log
.
d
(
"RammusPushIntentService"
,
"onNotification title is $title, summary is $summary, extras: $extras"
)
Log
Utils
.
d
(
"onNotification title is $title, summary is $summary, extras: $extras"
)
handler
.
postDelayed
({
handler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotification"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotification"
,
mapOf
(
...
@@ -36,7 +38,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
...
@@ -36,7 +38,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
}
}
override
fun
onMessage
(
context
:
Context
,
message
:
CPushMessage
)
{
override
fun
onMessage
(
context
:
Context
,
message
:
CPushMessage
)
{
Log
.
d
(
"RammusPushIntentService"
,
"onMessage title is ${message.title}, messageId is ${message.messageId}, content is ${message.content}"
)
Log
Utils
.
d
(
"onMessage title is ${message.title}, messageId is ${message.messageId}, content is ${message.content}"
)
handler
.
postDelayed
(
{
handler
.
postDelayed
(
{
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onMessageArrived"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onMessageArrived"
,
mapOf
(
"appId"
to
message
.
appId
,
"appId"
to
message
.
appId
,
...
@@ -50,7 +52,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
...
@@ -50,7 +52,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
override
fun
onNotificationOpened
(
p0
:
Context
?,
title
:
String
?,
summary
:
String
?,
extras
:
String
?)
{
override
fun
onNotificationOpened
(
p0
:
Context
?,
title
:
String
?,
summary
:
String
?,
extras
:
String
?)
{
Log
.
d
(
"RammusPushIntentService"
,
"onNotificationOpened title is $title, summary is $summary, extras: $extras"
)
Log
Utils
.
d
(
"onNotificationOpened title is $title, summary is $summary, extras: $extras"
)
handler
.
postDelayed
({
handler
.
postDelayed
({
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationOpened"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationOpened"
,
mapOf
(
"title"
to
title
,
"title"
to
title
,
...
@@ -61,7 +63,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
...
@@ -61,7 +63,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
}
}
override
fun
onNotificationReceivedInApp
(
p0
:
Context
?,
title
:
String
?,
summary
:
String
?,
extras
:
MutableMap
<
String
,
String
>?,
openType
:
Int
,
openActivity
:
String
?,
openUrl
:
String
?)
{
override
fun
onNotificationReceivedInApp
(
p0
:
Context
?,
title
:
String
?,
summary
:
String
?,
extras
:
MutableMap
<
String
,
String
>?,
openType
:
Int
,
openActivity
:
String
?,
openUrl
:
String
?)
{
Log
.
d
(
"RammusPushIntentService"
,
"onNotificationReceivedInApp title is $title, summary is $summary, extras: $extras"
)
Log
Utils
.
d
(
"onNotificationReceivedInApp title is $title, summary is $summary, extras: $extras"
)
handler
.
postDelayed
(
{
handler
.
postDelayed
(
{
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationReceivedInApp"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationReceivedInApp"
,
mapOf
(
"title"
to
title
,
"title"
to
title
,
...
@@ -75,7 +77,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
...
@@ -75,7 +77,7 @@ class RammusPushIntentService : AliyunMessageIntentService() {
}
}
override
fun
onNotificationClickedWithNoAction
(
context
:
Context
,
title
:
String
?,
summary
:
String
?,
extras
:
String
?)
{
override
fun
onNotificationClickedWithNoAction
(
context
:
Context
,
title
:
String
?,
summary
:
String
?,
extras
:
String
?)
{
Log
.
d
(
"RammusPushIntentService"
,
"onNotificationClickedWithNoAction title is $title, summary is $summary, extras: $extras"
)
Log
Utils
.
d
(
"onNotificationClickedWithNoAction title is $title, summary is $summary, extras: $extras"
)
handler
.
postDelayed
(
{
handler
.
postDelayed
(
{
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationClickedWithNoAction"
,
mapOf
(
RammusPushHandler
.
methodChannel
?.
invokeMethod
(
"onNotificationClickedWithNoAction"
,
mapOf
(
"title"
to
title
,
"title"
to
title
,
...
...
example/android/app/build.gradle
浏览文件 @
d1726609
...
@@ -71,4 +71,5 @@ dependencies {
...
@@ -71,4 +71,5 @@ dependencies {
implementation
"com.aliyun.ams:alicloud-android-third-push-oppo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-oppo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-vivo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-vivo:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-honor:$push_version"
implementation
"com.aliyun.ams:alicloud-android-third-push-honor:$push_version"
implementation
"com.blankj:utilcodex:1.31.1"
}
}
example/android/app/src/main/AndroidManifest.xml
浏览文件 @
d1726609
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
<application
<application
android:name=
".MyApplication"
android:name=
".MyApplication"
android:label=
"rammus_example"
android:label=
"rammus_example"
tools:replace=
"android:label"
android:usesCleartextTraffic=
"true"
android:icon=
"@mipmap/ic_launcher"
>
android:icon=
"@mipmap/ic_launcher"
>
<meta-data
<meta-data
...
@@ -64,13 +62,7 @@
...
@@ -64,13 +62,7 @@
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated=
"true"
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
>
android:windowSoftInputMode=
"adjustResize"
>
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name=
"io.flutter.embedding.android.SplashScreenDrawable"
android:resource=
"@drawable/launch_background"
/>
<!-- Theme to apply as soon as Flutter begins rendering frames -->
<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
<meta-data
...
...
example/android/app/src/main/kotlin/com/jarvanmo/rammus_example/MyApplication.kt
浏览文件 @
d1726609
package
com.jarvanmo.rammus_example
package
com.jarvanmo.rammus_example
import
com.jarvanmo.rammus.RammusPlugin
import
io.flutter.app.FlutterApplication
import
io.flutter.app.FlutterApplication
/***
/***
* Created by mo on 2019-06-25
* Created by mo on 2019-06-25
...
@@ -10,6 +9,5 @@ import io.flutter.app.FlutterApplication
...
@@ -10,6 +9,5 @@ import io.flutter.app.FlutterApplication
class
MyApplication
:
FlutterApplication
()
{
class
MyApplication
:
FlutterApplication
()
{
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
RammusPlugin
.
initPushService
(
this
)
}
}
}
}
\ No newline at end of file
example/lib/main.dart
浏览文件 @
d1726609
...
@@ -44,7 +44,6 @@ class _MyAppState extends State<MyApp> {
...
@@ -44,7 +44,6 @@ class _MyAppState extends State<MyApp> {
"公告信息"
,
"公告信息"
,
importance:
rammus
.
AndroidNotificationImportance
.
MAX
,
importance:
rammus
.
AndroidNotificationImportance
.
MAX
,
));
));
getDeviceId
();
rammus
.
setupNotificationManager
(
channels
);
rammus
.
setupNotificationManager
(
channels
);
rammus
.
onNotification
.
listen
((
data
)
{
rammus
.
onNotification
.
listen
((
data
)
{
...
@@ -115,9 +114,25 @@ class _MyAppState extends State<MyApp> {
...
@@ -115,9 +114,25 @@ class _MyAppState extends State<MyApp> {
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
title:
const
Text
(
'Plugin example app'
),
),
),
body:
Center
(
body:
Column
(
children:
[
Center
(
child:
Text
(
'Running on:
$_platformVersion
\n
'
),
child:
Text
(
'Running on:
$_platformVersion
\n
'
),
),
),
TextButton
(
onPressed:
()
{
getDeviceId
();
},
child:
Text
(
"getDeviceId"
),
),
TextButton
(
onPressed:
()
{
rammus
.
register
();
},
child:
Text
(
"register"
),
),
],
),
),
),
);
);
}
}
...
...
pubspec.yaml
浏览文件 @
d1726609
name
:
rammus
name
:
rammus
description
:
Flutter plugin for AliCloud push, including both android and ios. Receive background messages and notifications.
description
:
Flutter plugin for AliCloud push, including both android and ios. Receive background messages and notifications.
version
:
2.5.
0
version
:
2.5.
1
homepage
:
https://github.com/OpenFlutter/rammus
homepage
:
https://github.com/OpenFlutter/rammus
environment
:
environment
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论