0
votes

I am wondering are there any examples on Git of the implementation of Drive REST Api push notifications on an android app?

My app is built on GDAA currently but that doesn't support the kind of real time notifications I need for changes to files, and the documentation is not particularly clear on how to send the post request in java, where to send it etc.

I suspect what this user has working is what I need, but he did not post his full code. Google Drive REST API Notifications not working for changes in app folder

Thanks!

1
I suspect you're looking at writing a server app that converts change web hooks into Google Cloud Messages, or whatever the Firebase equivalent is. - pinoyyid
Thanks for your help! Just so I have got this right in my head: I would send the post via my android app with the receiver/callback URL pointing to a PHP file on my server, which would receive the notification, and given it is not an error message, notify FCM/GCM to send the push notification? Or by server app do you mean a little bit more than just a PHP script? Thanks. - ross franey
Yep. You've got it. - pinoyyid
And I've got 12 days to get it done! Haha thank you. - ross franey
Make sure that I've correctly understood your use case before you go down this route. It's really not trivial to set up the GCM/firebase aspect, and there is also a bunch of Android code to subscribe to the notifications. - pinoyyid

1 Answers

0
votes

You can try implementing a change listener :

You can use change listeners to receive notifications whenever a specified file or folder has changes to its contents or metadata. A change listener implements the ChangeListener interface for the ChangeEvent and receives a direct callback from the Drive service to a currently connected client application.

You can add a change listener by calling the addChangeListener method of the file or folder you want to receive notifications for. Listeners are only active for the durations of the current connection or until the removeChangeListener method is called on the same file or folder with the same callback parameter.

There is a working sample, see the ListenChangeEventsForFilesActivity sample in the Google Drive Android API Demos app.