I create a Google Sheet add-on but now I need to update the sheet when there is new update on my server. I found there are 2 options.
Which is the best option to pull data and update to Google Sheet for a published add-on?
Google just released Cloud Messaging Pub/Sub. This is a tool that covers exactly what you are trying to accomplish.
https://cloud.google.com/pubsub/overview
Pub/Sub is an API that is designed for application to application messaging. You need to set up your script as a push webhook endpoint. It isn't obvious, nor documented, but I figured it out through exploration. This is needed to set up you add-ons and server for push notifications instead of using pulling.
Get the published WebApp URL. It will look something like:
https://script.google.com/macros/s/AKfycbx7STHODJlW...EjvowTaO0mmZ3TA9Xsdq1/exec
Go back the the Developer Console from your script and choose Push under API & Auth.
Add the domain specific URL without the trailing 'exec' in my case :
https://script.google.com/macros/s/AKfycbx7STHODJlW...EjvowTaO0mmZ3TA9Xsdq1/
The form submit trigger only happens when someone submits a Google Form. I have no idea when and by what event your server is being updated.
If your server can submit an HTTP Request, you could use a Google Sheets API.
https://developers.google.com/google-apps/spreadsheets/
The installable time trigger would be a lot easier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.