Im trying to set up a dynamic link that is auto created when a item is added to a the firestore database. 1) How do I get the dynamic link to create using a cloud function? 2) When the link is generated how do I add it to the database?
> import * as functions from 'firebase-functions';
> import * as admin from 'firebase-admin';
>
>
> admin.initializeApp(functions.config().firebase);
>
>
> export const link_gen =
> functions.firestore.document('/Users/{userID}/Events/{eventsID}').onCreate((snapshot,
> context) => {
> console.log("Event Created - Starting Link Generaction")
> console.log("Starting Link Gen For Guest Upload")
>
> //getting room and event data strings
> const userID = context.params.userID
> const eventID = context.params.eventsID
> console.log(userID)
> console.log(eventID)
>
>
> //getting all data in the new event
> const data = snapshot.data()
> console.log(data)
>
> //creating the dynamic link service from firebase
> POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=APIKEY
> Content-Type: application/json
> console.log("running")
> { "longDynamicLink": "https://woke.page.link/Pages/gh/main.html?u=" + userID + "&e=" +
> eventID;
> }
>
>
> });
Aucun commentaire:
Enregistrer un commentaire