fcmex icon indicating copy to clipboard operation
fcmex copied to clipboard

Adding support for condition field

Open ks0m1c opened this issue 2 years ago • 0 comments

Naive implementation of incorporating conditions for pushing messages to topics.

condition | Optional, string | This parameter specifies a logical expression of conditions that determine the message target.

Supported condition: Topic, formatted as "'yourTopic' in topics". This value is case-insensitive. Supported operators: &&, \|\|. Maximum two operators per topic message supported.

Current library is built around the to field, however using condition field collides with the 'to' field. As below:

{:error, "Must use either \"registration_ids\" field or \"to\" field or \"condition\", not more than one\n"}

As such to support condition field, I have prevented the merge of the to field

Willing to add in the test cases and update docs if satisfactory.


Fcmex.push("Messages all of Athens but not Pheidippides",
  notification: %{
    title: "CITY.Athens not USER.Pheidippides",
    body: "Rejoice, we conquer"
  },
  condition: "'CITY.Athens' in topics && !('USER.Pheidippides' in topics)"
)

ks0m1c avatar Oct 27 '22 17:10 ks0m1c