I have an iOS app that I'm using with Cloud Firestore. I've read the documentation provided by firebase but I'm still unsure how this can be used with swift programming. Does anyone know or have experience with this firebase tigger function implementation with a swiftui app? How can I implement this?
Asked
Active
Viewed 316 times
1 Answers
2
You can use the Trigger Email Extension to send an email when you add a new document to a Firestore collection.
To use this, you'll have to:
- Install the extension into your Firebase project via the console (see instructions here)
- Add a new document to the collection you specified when setting up the extension. Here is some sample code that shows how to do this in Swift:
db.collection("mail").addDocument(data: [
"to": "someone@example.com",
"message": [
"subject": "Hello from Firebase",
"html": "This is an <code>HTML</code> email body."
]
]) { err in
if let err = err {
print("Error writing document: \(err)")
} else {
print("Document successfully written!")
}
}

Peter Friese
- 6,709
- 31
- 43