0

I have a react native app and in the order, details screen its contain one button when I click it I want to call a function that's will send a notification to a specific device I have his FCM so how to handle these, I don't want to trigger the real-time database just click and calling,

orderDetails.js

  <TouchableOpacity onPress={() => // here i want call function i wrote in index.js so?} >
          <Text style={{ color: "#fff", fontSize: 17 }}>Completed</Text>
  </TouchableOpacity>

index.js

exports.sendN = functions.https.onRequest((req, res) => {
    try {
            const response = await admin.messaging().sendToDevice(registrationTokens, payload);
            console.log('Successfully sent message:', response);
        }
        catch (error) {
            console.log('Error sending message:', error);
        }
        return null;
});

1 Answers1

0

You can either use Callable functions as shown here, or call the HTTP function directly from your Android code as shown here. The client-side JavaScript code in the latter case will just be calling a regular HTTP URL, so any any result from this list should be a good starting point. This one is a bit old, but not bad: HTTP GET request in JavaScript?

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