According to the documentation it should be possible to register a notification channel for changes to the app folder of my app, using setSpaces("appDataFolder")
.
However, I only get an initial sync
notification when setting up the channel, but no change
notifications when I change something in the app folder.
If I use setSpaces("drive")
or omit the setSpaces()
altogether and change something in regular drive space, I receive change
notifications alright.
I didn't find anything about watching for changes in the app folder, so I hope someone here can help me.
This is how I set up the channel, where mDrive
is a fully initialized and authorized instance of com.google.api.services.drive.Drive
channelId = UUID.randomUUID().toString();
channelExpiration = System.currentTimeMillis() + CHANNEL_LIVETIME_MILLIS;
Channel channel = new Channel();
channel.setType("web_hook");
channel.setId(channelId);
channel.setAddress(DRIVE_API_CALLBACK_RECEIVER_URL);
channel.setToken("...");
channel.setExpiration(channelExpiration);
Channel result = mDrive.changes().watch(channel).setSpaces("appDataFolder").execute();
Is there a scope where you set this up? Make sure you have a broad enough scope to include 'appDataFolder'. By this I mean you should be able to get some results from this (from here):
I think the above might be your problem. Whereever you are setting scope make sure to include the
drive.appfolder
or more formallyFurthermore, are you checking if result is null? You really should put the
Channel result =...
line in atry {} catch(IOExeption e) {}
and print the error if there is one like in this example (from here).Which for you code should look like this: