sae*_*eid 3 dart firebase flutter firebase-cloud-messaging
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print('Handling a background message ${message.messageId}');
}
Run Code Online (Sandbox Code Playgroud)
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
Run Code Online (Sandbox Code Playgroud)
我可以使用这些代码片段显示后台通知。但是有什么办法可以不让某些特定的通知在后台显示呢?
例如我不想显示通知data = {title = "call"}
小智 5
from the sender device u have to send data only notification
await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'key=$serverKey',
},
body: jsonEncode(
<String, dynamic>{
'data': <String, dynamic>{
'id': '2',
'status': 'done'
},
'to': userToken,
"collapse_key": uid,
},
),
);
Run Code Online (Sandbox Code Playgroud)