我正在使我的应用程序作为一个新手开发人员,我希望用户发送通知的位置在设备上使用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"},
});发布于 2021-10-20 20:38:35
您使用的筛选器错误。但是我也得到了授权错误
示例:
"filters": [
{"field": "tag", "key": "level", "relation": "=", "value": "10"},
{"operator": "OR"}, {"field": "amount_spent", "relation": ">", "value": "0"}],https://stackoverflow.com/questions/65587725
复制相似问题