1
votes

I have an Android-based app and I'm developing a Glass app as a companion.

Code for the app lives in two places:

  • Web app (OAuth authentication/token creation, creating the subscription, handling the notify callbacks from Google server)
  • Android app (creating sharing contact, delete sharing contact and create bundle cover for a "photo album")

After handling all of the OAuth authentication and communicating with the Mirror API, the user has the ability in the Android app to creating a sharing contact. Part of that process includes the creation of a timeline item that serves as the bundle cover for a photo album.

On Glass, as the user shares photos with that contact, the notify handler in my web app assigns the photos to the bundle created when the sharing contact was established.

All of this works fine - no problems there.

What I'm running into is that after 7 days, the timeline cards begin to fall from the Glass interface. This includes my bundle cover for the "photo album".

Obviously I need to update the bundle cover to remain active, but I'm not quite sure how to do that (without quickly ripping through my quota, that is). Using the Mirror API, I've been able to retrieve the items from the timeline, then check each one for my bundle cover (based on bundle ID and isBundleCover flag) - but that is horribly inefficient when it comes to preserving my 1000 requests per day. Am I simply using the bundle in a way that it was not intended for?

Is there an easier, more effective way of fetching the bundle cover and simply updating it so it doesn't fall off the timeline after 7 days? In a way, it seems like I shouldn't need to update the bundle every time a new photo is shared, but I'm not sure about an alternative.

As I mentioned, the bundle is created in the Android app and that ID is submitted to the backend database shared by both the web app and the Android app. Short of querying that db using the bundleID to get the original ItemID for the bundle, I'm not sure how to make the bundle ItemID accessible in the notify handler.

Thank you for any suggestions!

1

1 Answers

3
votes

As you mentioned the most efficient method when it comes to preserving API quota would be to save the itemID of your bundle cover in your own datastore and retrieve it from there when needed

Apart from that there are some things you can do to make finding the card in the timeline via the Mirror API easier, since the timeline.list method offers some additional parameters to narrow down the results.

  1. ?bundleId=yourBundleId

    This will only return results with the provided bundleId, depending on how many cards are in your bundle, you might find the necessary card on the first result page, so that would only need one API request

  2. &sourceItemId=something

    If your bundles are getting rather large so that the bundle cover won't be found on the first result page, one thing you can do is to additionally define a sourceItemId which you only set for the bundle cover and none of the other cards inside of the bundle. That way looking for bundleId + sourceItemId (which you can also set to the same bundleId to make it easier) will only have one item, the bundle cover, in the result.

Using those methods you should be able to find the correct card in one request and update it in a second request.