前往
大廳
主題

Send Mail Using Firebase Cloud Function

夏洛爾 | 2022-03-15 01:40:02 | 巴幣 0 | 人氣 395

This post collects the information that may need when developing mail service with Firebase Cloud Function. Wish developers can save time when run into issues.

Suggested tutorial

Suggested Example

About Android Notification Channel
Since Android need the notification channel be set after Android O,the app must set channel id and the messaging that intent to trigger notification need to specify channel.
1.About set the channels on app side, please see Unity Mobile Notificaiton or set in any other way
2.About how to specify channel in Cloud Function, please see
--Firebase example for specifing android attributes and USING "send()" to send message (use sendToDevice() as the suggested example (
email-confirmation | Github) would fail, it seems to be legacy API and need another legacy format)
--StackOverflow for message format

If want to use "environment variables" to save account information of gmail
1.Could set environment variables with console UI, read Using Environment Variables
2.Use process.env.Variable_NAME to access variable, read Configure your environment

If encountered error after deployed
1.Go to Google Cloud Platform
2.Search "Cloud Founction" and enter page
3.Check the log

If log showed "Error: cannot find module"
1.Check whether you install module in right path (should be "cd functions" in command)
2.Read the answer in StackOverflow

If log showed "Missing credentials for "PLAIN"
1.While sending mail require login information of gmail,  if the attempt to access of the variable like "process.env.{var}" or "functions.config().{var}" failed, it would lead to the empty of login information and cause this error msg.
2.Check the "If want to use "environment variables" to save account information of gmail" above
3.process.env and functions.config() are independent, make sure you use same family of read and set variables

If log showed "Invalid login: Application-specific password"
1.account that enabled 2-factor authentication can't use your regular password to access Gmail programmatically
2.Read the answer  in StackOverflow

創作回應

更多創作