Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aliyun_push_clx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
aliyun_push_clx
Commits
90adfc27
提交
90adfc27
authored
9月 25, 2025
作者:
史晓晨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:调试Android处于前台时控制通知展示
上级
2a36a2f2
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
113 行增加
和
16 行删除
+113
-16
.gitignore
android/.gitignore
+11
-0
gradle-wrapper.properties
android/gradle/wrapper/gradle-wrapper.properties
+7
-0
AliyunPushMessageReceiver.java
...n/java/com/aliyun/ams/push/AliyunPushMessageReceiver.java
+0
-1
AliyunPushPlugin.java
...d/src/main/java/com/aliyun/ams/push/AliyunPushPlugin.java
+0
-0
AppLifecycleObserver.java
...c/main/java/com/aliyun/ams/push/AppLifecycleObserver.java
+57
-0
android.dart
example/lib/android.dart
+26
-0
ios.dart
example/lib/ios.dart
+2
-2
aliyun_push.dart
lib/aliyun_push.dart
+10
-13
没有找到文件。
android/.gitignore
0 → 100644
浏览文件 @
90adfc27
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
android/gradle/wrapper/gradle-wrapper.properties
0 → 100644
浏览文件 @
90adfc27
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout
=
10000
validateDistributionUrl
=
true
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
android/src/main/java/com/aliyun/ams/push/AliyunPushMessageReceiver.java
浏览文件 @
90adfc27
...
...
@@ -48,7 +48,6 @@ public class AliyunPushMessageReceiver extends MessageReceiver {
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
AliyunPushLog
.
e
(
REC_TAG
,
"key "
+
entry
.
getKey
()
+
" value "
+
entry
.
getValue
());
}
return
super
.
showNotificationNow
(
context
,
map
);
}
...
...
android/src/main/java/com/aliyun/ams/push/AliyunPushPlugin.java
浏览文件 @
90adfc27
差异被折叠。
点击展开。
android/src/main/java/com/aliyun/ams/push/AppLifecycleObserver.java
0 → 100644
浏览文件 @
90adfc27
package
com
.
aliyun
.
ams
.
push
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.os.Bundle
;
public
class
AppLifecycleObserver
implements
Application
.
ActivityLifecycleCallbacks
{
private
int
activityCount
=
0
;
private
boolean
isAppForeground
=
false
;
public
AppLifecycleObserver
(
Application
application
)
{
application
.
registerActivityLifecycleCallbacks
(
this
);
}
public
boolean
isAppForeground
()
{
return
isAppForeground
;
}
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
}
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
activityCount
++;
// 从后台切换到前台
if
(
activityCount
==
1
)
{
isAppForeground
=
true
;
}
}
@Override
public
void
onActivityResumed
(
Activity
activity
)
{
}
@Override
public
void
onActivityPaused
(
Activity
activity
)
{
}
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
activityCount
--;
// 从前台切换到后台
if
(
activityCount
==
0
)
{
isAppForeground
=
false
;
}
}
@Override
public
void
onActivitySaveInstanceState
(
Activity
activity
,
Bundle
outState
)
{
}
@Override
public
void
onActivityDestroyed
(
Activity
activity
)
{
}
}
example/lib/android.dart
浏览文件 @
90adfc27
...
...
@@ -89,6 +89,32 @@ class _AndroidPageState extends BaseState<AndroidPage> {
},
child:
const
Text
(
'清除所有通知'
)),
));
children
.
add
(
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10.0
),
child:
ElevatedButton
(
onPressed:
()
{
_aliyunPush
.
showNoticeWhenForeground
(
true
).
then
((
result
)
{
var
code
=
result
[
'code'
];
if
(
code
==
kAliyunPushSuccessCode
)
{
showOkDialog
(
'设置前台显示通知成功'
);
}
});
},
child:
const
Text
(
'前台显示通知'
)),
));
children
.
add
(
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10.0
),
child:
ElevatedButton
(
onPressed:
()
{
_aliyunPush
.
showNoticeWhenForeground
(
false
).
then
((
result
)
{
var
code
=
result
[
'code'
];
if
(
code
==
kAliyunPushSuccessCode
)
{
showOkDialog
(
'设置前台不显示通知成功'
);
}
});
},
child:
const
Text
(
'前台不显示通知'
)),
));
children
.
add
(
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10.0
),
...
...
example/lib/ios.dart
浏览文件 @
90adfc27
...
...
@@ -23,7 +23,7 @@ class _IOSPageState extends BaseState<IOSPage> {
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10.0
),
child:
ElevatedButton
(
onPressed:
()
{
_aliyunPush
.
show
IOS
NoticeWhenForeground
(
true
).
then
((
result
)
{
_aliyunPush
.
showNoticeWhenForeground
(
true
).
then
((
result
)
{
var
code
=
result
[
'code'
];
if
(
code
==
kAliyunPushSuccessCode
)
{
showOkDialog
(
'设置前台显示通知成功'
);
...
...
@@ -36,7 +36,7 @@ class _IOSPageState extends BaseState<IOSPage> {
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10.0
),
child:
ElevatedButton
(
onPressed:
()
{
_aliyunPush
.
show
IOS
NoticeWhenForeground
(
false
).
then
((
result
)
{
_aliyunPush
.
showNoticeWhenForeground
(
false
).
then
((
result
)
{
var
code
=
result
[
'code'
];
if
(
code
==
kAliyunPushSuccessCode
)
{
showOkDialog
(
'设置前台不显示通知成功'
);
...
...
lib/aliyun_push.dart
浏览文件 @
90adfc27
...
...
@@ -245,6 +245,16 @@ class AliyunPush {
return
listResult
;
}
/// 设置通知在应用前台时是否展示
///
/// @param enable 是否展示
/// @return 返回值
Future
<
Map
<
dynamic
,
dynamic
>>
showNoticeWhenForeground
(
bool
enable
)
async
{
Map
<
dynamic
,
dynamic
>
result
=
await
methodChannel
.
invokeMethod
(
'showNoticeWhenForeground'
,
{
'enable'
:
enable
});
return
result
;
}
// ***************** Android专用接口 *****************
///注册厂商通道
Future
<
Map
<
dynamic
,
dynamic
>>
initAndroidThirdPush
()
async
{
...
...
@@ -417,19 +427,6 @@ class AliyunPush {
return
apnsDeviceToken
;
}
/// 设置iOS通知在应用前台时是否展示
///
/// @param enable 是否展示
/// @return 返回值
Future
<
Map
<
dynamic
,
dynamic
>>
showIOSNoticeWhenForeground
(
bool
enable
)
async
{
if
(!
Platform
.
isIOS
)
{
return
{
'code'
:
kAliyunPushOnlyIOS
,
'errorMsg'
:
'Only support iOS'
};
}
Map
<
dynamic
,
dynamic
>
result
=
await
methodChannel
.
invokeMethod
(
'showNoticeWhenForeground'
,
{
'enable'
:
enable
});
return
result
;
}
Future
<
bool
>
isIOSChannelOpened
()
async
{
if
(!
Platform
.
isIOS
)
{
return
false
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论