Skip to content

Commit 62ffa11

Browse files
pufPoojaB26
andauthored
Puf/cloud functions testing (#313)
* Update cloud-functions.md Add description of testing push notifications without writing to Firestore (by using the testing functionality built into the Google Cloud console). --------- Co-authored-by: PoojaB26 <[email protected]>
1 parent 47ab603 commit 62ffa11

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

docs/ff-concepts/adding-customization/cloud-functions.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,44 @@ For this example, we'll use the result (i.e., generated logo image URL) and set
245245
<div class="video-container"><iframe src="https://www.loom.
246246
com/embed/0c4306c1951a4d9099aa96324c7561af?sid=69709110-ad60-4e98-bf53-36a50a99e425" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
247247

248+
## Testing Cloud Functions by sending push notifications without writing to Firestore
249+
250+
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).
251+
252+
Here's how to test FlutterFlow's `sendUserPushNotificationsTrigger` function in the Google Cloud console:
253+
254+
1. Open your browser and navigate to the following URL:
255+
`https://console.cloud.google.com/functions/details/us-central1/sendUserPushNotificationsTrigger?env=gen1&project=<projectID>&tab=testing`
256+
\
257+
In here:
258+
- Replace `<projectID>` with your GCP or Firebase project.
259+
- If you want to test a different Cloud Function, update `sendUserPushNotificationsTrigger` with the relevant cloud function name.
260+
2. Paste the following JSON into the <kbd>Configure Triggering Event</kbd> text area.
261+
- If you want to test a different Cloud Function, update `sendUserPushNotificationsTrigger` with the relevant cloud function name.
262+
```json
263+
{
264+
"value": {
265+
"name": "projects/<projectID>/databases/(default)/documents/sendUserPushNotificationsTrigger/<documentID>",
266+
"fields": {
267+
"scheduled_time": { "stringValue": "" },
268+
"initial_page_name": { "stringValue": "" },
269+
"notification_title": { "stringValue": "Your friends are missing you!" },
270+
"notification_text": { "stringValue": "Please come back to Nanochat" },
271+
"user_refs": { "stringValue": "users/VXu6EvFMl5M8KMXriYRvFEWTFHA2" }
272+
}
273+
}
274+
}
275+
```
276+
3. In the `name` property:
277+
- Replace `<projectID>` with your GCP or Firebase project.
278+
- Replace `<documentID>` with the ID of the document. This document must already exist in Firestore.
279+
- If you're testing another function than `sendUserPushNotificationsTrigger`, update `ff_user_push_notifications` with the collection where the document is written.
280+
4. Update the values under the `fields` property for the message you want to send.
281+
\
282+
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.
283+
5. Click the <kbd>TEST THE FUNCTION</kbd> button.
284+
285+
The Cloud Function will now run and gather the relevant entries from Google Cloud Logging.
248286

249287

250288
## FAQs
@@ -299,6 +337,3 @@ Follow the steps below to fix the issue:
299337
</p>
300338
</details>
301339

302-
303-
304-

0 commit comments

Comments
 (0)