DEV Community

Pierre
Pierre

Posted on

How to setup React Native / expo push notification according to different types of notification

Hi, I am actually desperate.
I need to setup push notification on my IOS/Android app, I buold with React Native / Expo.

I could setup a simple push notification follwing this and this but my big problem is the following:

I have several sensors into several field. A fermer have installed the App on his/her smartphone and they can monitor the fields.

The farmers need to be alarmed with a push notification, when a sensor measures a measure under a threshold value. A farmer can own several fields (let's say 6 fields)

I want that farmer can active or not a field to be monitor and to be alarmed for the active fields.

For example,

  • if he do not active a field, he should never receive a push notification, excepted for the general notification (let's say the type "general"
  • if he active the field 2 and 4 and 5, he should reveive only push notification matching to the sensors on field 2,4 and 5.

On my PHP scrypt (on my remote server) I can send push notification, but the script should send a push notification to the IOS/Addroid which are registered for the active field. (2,4 and 5 according to my above example)

I spent days and weeks to search how I could registered the App of a smartphone according to my needs.

  • Step 1: the farmer open the App. The app is registred for push notification
  • Step 2: The farmer go the the setting view
  • Step 3: The farmer chose and select the fields he want to monitor

How Expo notification can save the selected field as channel or categories?
And how can my php script know on which devise it has to send the push notification

Other scenarios:
Smartphone 1 saved the fields 1, 2 ,3
Samrtphone 2 saved the field 2,4,6
Smartphone 3 saved the field 3
Smartphone 4 saved the field 4,5
Smartphone 5 saved the field 6

On the morning, a station on field 6 run into alarm. How can I setup Expo to send a push notification to the Samrtphone 2 and 5 only

On the after noon, the stations on fields 2 and 4 run into alarm. How can I setup Expo to send a notification to the Smartphone 1,2 and 4 only?

I want to inform an update, how can I send a push notification to all Samrtphone

I kindly thank for your help, because I am lost :)

Cheers

Top comments (0)