简体   繁体   中英

Sending push notification to a specific user using firebase with expo notifications

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

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

在此处输入图像描述

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

在此处输入图像描述

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM