Send iOS app badge notifications when Google Docs file changes

I’m pretty new to push notifications but have been developing iOS apps for some time now. I want to show a badge number (like the red circle with a number that appears on Mail or Messages apps) on my app icon whenever someone makes changes to a Google Docs file.

My main questions are:

  • Can this actually be done with Google Docs?
  • What would be the best approach to detect document changes?
  • How do I trigger the badge notification from my iOS app?

I’ve been searching around but most examples I find are for basic push notifications, not specifically for Google Docs integration. Any guidance on whether this is possible and what APIs or services I should look into would be really helpful.

Dealt with this integration 6 months ago - hit some gotchas that’ll save you time. The Google Drive API approach works well, but auth gets tricky with shared docs when multiple users are editing. Your backend needs to handle OAuth and keep refresh tokens since they expire.

One thing that bit me: Google’s webhook payload doesn’t always show what actually changed, so you’ll need extra API calls to figure that out. On iOS, use silent push with content-available so your app processes updates when backgrounded. Badge updates won’t work if users disabled notifications, so have a fallback for when they manually open the app.

I built this exact thing last year with Google Drive’s push notifications. You’ll need to set up a channel subscription through the Drive API’s watch endpoint - it monitors file revisions. When files change, Google hits your server with a webhook (can’t send these directly to iOS because of Apple’s sandbox). Your backend catches the webhook and fires a silent push to your app via APNs. The iOS app gets it in the background and updates the badge using UIApplication.shared.applicationIconBadgeNumber. Watch out for rate limiting though - Google Docs spams revision events during editing sessions. I added a debounce on the server side so users don’t get flooded with badge updates. Also, don’t forget channel expiration - subscriptions die after about 24 hours and need renewal.

for sure! you can use google drive api to check for file changes. set up webhooks to trigger notifications, then send those to your app using apns for badge updates. just keep in mind you’ll need a backend for the webhook stuff.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.