0

I'm trying to send push notifications to a certain user when a certain function executes ! I have seen that Firebase cloud messaging is no supported on IOS , so i switched to expo-notifications and i have seen tutorials but all of them require a backend server to send these notifications ! and m using firebase as my backend ( firebase firestore ) ! So can that be possible to do with firebase only ?

I wanna send the notification when this function executes

const onCancel = async (dateDetails) => {
   setIsSubmitting(true);
   if (!dateDetails.accepted) {
     await deleteDoc(doc(db, "Dates", dateDetails.dateId)).then(() => {
       setIsSubmitting(false);
       Toast.show({
         topOffset: 60,
         type: "success",
         text1: "Date Deleted Successfully",
         text2: " ",
       });
     });
     fetchMyDates().then((res) => {
       setNewDatesOnChild(res);
     });
     //Show a toast
   } else {
     setIsSubmitting(false);
     Alert.alert(
       "Your order has already been accepted Please call this number to Cancel your order !"
     );
   }
 };

If there is another way of sending push notifications Please let me know

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Zaki Kendil
  • 237
  • 2
  • 9

1 Answers1

0

The Expo documentation on sending notifications is pretty clear that you should call its backend from your own backend, so not from the client-side app directly.

enter image description here

In that sense it seems very similar to sending messages with Firebase Cloud Messaging, which shows this diagram for the same use-case:

enter image description here

Here too the calls must come from a trusted environment, and can't be secure made from the client-side app itself.

For more on this, including examples how to implement the sending of messages in a trusted environment, see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807