diff --git a/docs/ff-concepts/adding-customization/cloud-functions.md b/docs/ff-concepts/adding-customization/cloud-functions.md index 70ea8285..b9ccb092 100644 --- a/docs/ff-concepts/adding-customization/cloud-functions.md +++ b/docs/ff-concepts/adding-customization/cloud-functions.md @@ -245,6 +245,44 @@ For this example, we'll use the result (i.e., generated logo image URL) and set
+## Testing Cloud Functions by sending push notifications without writing to Firestore + +The Google Cloud console has built-in functionality to allow you to trigger a Cloud Function for testing. This means that after deploying Cloud Functions, you can test them without writing to Firestore (either from FlutterFlow or otherwise). + +Here's how to test FlutterFlow's `sendUserPushNotificationsTrigger` function in the Google Cloud console: + +1. Open your browser and navigate to the following URL: +`https://console.cloud.google.com/functions/details/us-central1/sendUserPushNotificationsTrigger?env=gen1&project=&tab=testing` +\ + In here: + - Replace `` with your GCP or Firebase project. + - If you want to test a different Cloud Function, update `sendUserPushNotificationsTrigger` with the relevant cloud function name. +2. Paste the following JSON into the Configure Triggering Event text area. + - If you want to test a different Cloud Function, update `sendUserPushNotificationsTrigger` with the relevant cloud function name. + ```json + { + "value": { + "name": "projects//databases/(default)/documents/sendUserPushNotificationsTrigger/", + "fields": { + "scheduled_time": { "stringValue": "" }, + "initial_page_name": { "stringValue": "" }, + "notification_title": { "stringValue": "Your friends are missing you!" }, + "notification_text": { "stringValue": "Please come back to Nanochat" }, + "user_refs": { "stringValue": "users/VXu6EvFMl5M8KMXriYRvFEWTFHA2" } + } + } + } + ``` +3. In the `name` property: + - Replace `` with your GCP or Firebase project. + - Replace `` with the ID of the document. This document must already exist in Firestore. + - If you're testing another function than `sendUserPushNotificationsTrigger`, update `ff_user_push_notifications` with the collection where the document is written. +4. Update the values under the `fields` property for the message you want to send. +\ +The `fields` in the example above are for FlutterFlow's built-in `sendUserPushNotificationsTrigger` function. If you're testing a different Cloud Function, you will need to update the `fields` for the code in *that* function. +5. Click the TEST THE FUNCTION button. + +The Cloud Function will now run and gather the relevant entries from Google Cloud Logging. ## FAQs @@ -299,6 +337,3 @@ Follow the steps below to fix the issue:

- - -