小编kar*_*sim的帖子

如何在 dart post 请求中发送数组

我尝试使用其registration_ids.

这是我的代码:

List<String> tokens=["token1","token2"];
final  url='https://fcm.googleapis.com/fcm/send';
 http.post(url,headers:{
  "Accept": "application/json",
  "Authorization":"key=mykey"
  ,"project_id":"proID"
},
body: 
  {
 "registration_ids" :tokens ,
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
 }
}
Run Code Online (Sandbox Code Playgroud)

当应用程序运行时,显示此错误:

发生异常。_CastError(类型“List”不是类型转换中类型“String”的子类型)

如何修复它?

android dart flutter firebase-cloud-messaging

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

dart ×1

firebase-cloud-messaging ×1

flutter ×1