我尝试按照文档进行操作,但无法使其工作我不知道新版本中的授权如何工作我尝试下载新的私钥,但不知道如何使用它使用该授权方法向特定用户发送通知
这个我的代码
void sendPushMessage(String token, String body, String title) async {
await http.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization':
'private key'
},
body: jsonEncode(<String, dynamic>{
'Priority': 'high',
'data': <String, dynamic>{
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
'status': 'done',
'title': title,
"sound": "test.wav",
},
'notification': <String, dynamic>{
'title': title,
'body': body,
"sound": "test.wav",
'android_channel_id': ''
},
'to': token
}));
}
如何升级到这个
void sendPushMessage(String token, String body, String title) async {
await http.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization':
'how do I get this key'
},
body: jsonEncode(<String, dynamic>{
"message": {
"token": "token",
"notification": {
"body": "This is an FCM notification message!",
"title": "FCM Message",
"sound": "sound.mp3"
}
}
}));
}