Reputation: 1203
I made a Facebook game for Windows 8 where users can connect to Facebook and share their scores.
When users close the game and later reopen it, I have their UserName and User ID cached; however, I get their image with the graph api url.
My problem occurs when users open my app when they are offline. I can display their name correctly, because it is cached, but I cannot display their image, because it is not cached. How can I cache their image in my WinJS app so that it is still available when they are offline?
Here is my code to show their image:
$('#FbUserExterno img').attr('src', 'https://graph.facebook.com/' + RS.getUserId() + '/picture');
Thanks
Upvotes: 0
Views: 404
Reputation: 23764
At the point you are connected, download the image file and save it locally (using WinJs.xhr, for instance).
You can then use the ms-appdata:///local/ scheme for the image source pointing to the downloaded file in local storage.
Of course, you'll want to refresh the image in local storage at some frequency, perhaps re-downloading it when you detect you have a network connection.
Upvotes: 3