OneSignal / onesignal-dotnet-api

Other
13 stars 11 forks source link

[question]: How do I send a notification filtering the users role OR location? #41

Open VictorGazzinelli opened 1 year ago

VictorGazzinelli commented 1 year ago

How can we help?

I've got a use case to send users a push notifcation based on their role OR location. How do I use the CreateNotificationAsync method to send a notification based on such criteria?

According to the documentation, in order to correctly specify this behavior, I believe the final json data would be something like:

{
  ...
  "filters": [
    {"field": "tag", "key": "is_admin", "relation": "=", "value": "true"},
    {"operator": "OR"}, {"field": "location", "lat": "37.5426574", "long" : "-122.3019626", "radius": "100" }
  ]
}

With this, I believe there is two issues:

  1. The OR operator must be suported for filters - a Pull Request submited by @bnoffer should fix this.
  2. The lat, long and radius props must be added to the Filter class/model.

Any ideia how can I achieve this? Let me know if i can help submiting a PR.

Victor Gazzinelli

Code of Conduct

bnoffer commented 1 year ago

Hi @VictorGazzinelli, I had the same demand in regards to the OR operator and actually was a bit confused that OneSignal does not follow their own specification here. But it looks to me as if they are using some kind of code generator and that there is no "real" development happening on this project. So the issue probably lies in the code generator being used, since the proper values are in the spec.

Would be nice to know what is being used, so the issue for the code generation can be addressed to the proper party.

I forked this repo and I am using a modified version of the library, it is not up-to-date though. If it helps you can find it here: https://github.com/bnoffer/onesignal-dotnet-api/tree/support_or_operator_for_notification_filters and build a Nuget yourself.

I know, it is not the recommended way to do it, but it works.