Flutter / OneSignal:我在使用 postNotificationWithJson 时遇到问题

问题描述

作为新手开发人员,我正在为我制作一个应用程序,我希望用户使用我的应用程序中的 onesignal postNotificationWithJson(和过滤器)功能按设备上的位置发送通知,但我收到一个错误,我一直在处理这个问题错误 2 天,但我还没有找到解决方案。

错误

OnesignalRestClient: POST RECEIVED JSON: {"errors":["Please include a case-sensitive header of Authorization: Basic \u003cYOUR-REST-API-KEY-HERE\u003e with a valid REST API key."],"reference":["https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids"]}
W/Onesignal( 7314): HTTP code: 400 create notification Failed
E/Flutter ( 7314): [ERROR:Flutter/lib/ui/ui_dart_state.cc(184)] Unhandled Exception: PlatformException(Onesignal,Encountered an error attempting to post notification: {"errors":["Please include a case-sensitive header of Authorization: Basic <YOUR-REST-API-KEY-HERE> with a valid REST API key."],"reference":["https:\/\/documentation.onesignal.com\/docs\/accounts-and-keys#section-keys-ids"]},{reference: [https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids],errors: [Please include a case-sensitive header of Authorization: Basic <YOUR-REST-API-KEY-HERE> with a valid REST API key.]},null)

代码删除过滤器行时错误消失。):

    var response = await Onesignal.shared.postNotificationWithJson({
  "Authorization":
      "Basic xxxxx","filters": [
    {
      "field": "location","lat": "36.1185207","long": "36.2526271","radius": "800",}
  ],"headings": {"en": "APP NAME"},"contents": {"en": "Click for more information."},"data1": {"name": "Markos","LastName": "Baslik"},"data2": {"idName": "KNARNYR"},});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)