flutter - 即使应用程序最小化也会出现系统警报窗口
问题描述
我正在使用 Firebase 开发一个交付应用程序,通过 firebaseMessaging 到达手机的通知带有一个显示订单数据的对话框是正常的,但是当应用程序最小化时,这个对话框必须出现,而这不会不会发生,只有通知出现在手机顶部,我正在使用图书馆系统警报(system_alert_window 0.4.2 + 2),即使这样它也只会在应用程序处于前台时出现。
注意:我已经在设置中发布了该应用程序以显示有关其他应用程序的一些信息。
使用这些权限:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE " />
<uses-permission android:name="android.permission.TYPE_APPLICATION_OVERLAY" />
通知到达时:
firebaseMessaging.requestNotificationPermissions();
firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
//quando o app está em primeiro plano
MostrarInformacaodaNotificacao(context,message);
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
//quando o app está em segundo plano
//esse System alertWindow era para aparecer quando o app estivesse minimizado.
SystemAlertWindow.showSystemWindow(
height: 230,
header: header,
body: body,
footer: footer,
margin: SystemWindowMargin(left: 8, right: 8, top: 100, bottom: 0),
gravity: SystemWindowGravity.TOP,
notificationTitle: "Incoming Call",
notificationBody: "+1 646 980 4741");
},
);
}
SystemWindowFooter footer = SystemWindowFooter(
buttons: [
SystemWindowButton(
text: SystemWindowText(text: "Simple button", fontSize: 12, textColor: Color.fromRGBO(250, 139, 97, 1)),
tag: "simple_button", //useful to identify button click event
padding: SystemWindowPadding(left: 10, right: 10, bottom: 10, top: 10),
width: 0,
height: SystemWindowButton.WRAP_CONTENT,
decoration: SystemWindowDecoration(
startColor: Colors.white, endColor: Colors.white, borderWidth: 0, borderRadius: 0.0),
),`
在前台显示订单详细信息的对话框:
void MostrarInformacaodaNotificacao(BuildContext context,Map<String, dynamic> Dados){
double latponto=double.parse(Dados["data"]["lat_ponto"]);
double longponto=double.parse(Dados["data"]["long_ponto"]);
String end_ponto=Dados["data"]["end_ponto"];
String nome_ponto=Dados["data"]["nome_ponto"];
String Quant_itens=Dados["data"]["quant_itens"];
String telefone=Dados["data"]["telefone"];
String id_Doc=Dados["data"]["id_doc"];
String hora=Dados["data"]["hora"];
Pedido detalheCorrida=Pedido();
detalheCorrida.lat_ponto=latponto.toString();
detalheCorrida.long_ponto=longponto.toString();
detalheCorrida.end_ponto=end_ponto;
detalheCorrida.nome_ponto=nome_ponto;
detalheCorrida.quant_itens=Quant_itens;
detalheCorrida.telefone=telefone;
detalheCorrida.id_doc=id_Doc;
detalheCorrida.hora=hora;
showDialog(
context:context,
barrierDismissible: false,
builder: (BuildContext context)=>NotificacaoDialog(detalheCorrida:detalheCorrida) );
}
解决方案
推荐阅读
- java - Spring Boot 日志记录覆盖颜色
- arduino - 简易HC-05蓝牙安卓通讯
- python - 如何在没有行网格的python中在reportlab中创建表?
- c++ - VSC Ubuntu 20.04 中的“不允许使用属性控制台”问题
- google-sheets - Google Sheets Countif range is greater than range
- c - How to work around compiler built-in types in C standard header files
- java - How to get date from a string without formatting?
- javascript - how i can write a component without error in syntax certainly inside (return) ,,i have problem with a jsx
- mysql - How to insert multiple row with different ID in Laravel
- angular - How to fetch specific JSON data in Angular