Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome.storage.sync doesn't sync between machines

I have a simple extensions that saves some data to chrome storage

var dt = new Date();
var item = {};
item[$('#qteSymb').text() + "-" + guid()] = $('#newnote').val() + "-:-" + $.datepicker.formatDate('mm/dd/yy', dt) + " " + dt.getHours() + ":" + (dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes());           
chrome.storage.sync.set(item, function(){
    renderNotes();
});   

This works fine locally - my extension is working as intended - but it doesn't sync back to another computer. I am assuming the sync is ON on both computers because the bookmarks, extensions, etc. sync just fine.

Thank you!

like image 456
americanslon Avatar asked Jul 30 '13 22:07

americanslon


1 Answers

So I finally figured this out. When not using Chrome Web Store your manifest file should include a key (https://developer.chrome.com/extensions/manifest.html#key)

...
"key":"myawesomeextension"
...

Without this every time you install the extension on a different device (through chrome://extensions/ --> Load unpacked extension) it gets a new id and therefore the data being synced doesn't get matched to the correct extension - same extension with different ids = two different extensions in the eyes of Chrome.

There is no need for a key once the extension is in Chrome Web Store. Hope this helps somebody keep some hair at some point.

like image 75
americanslon Avatar answered Sep 26 '22 23:09

americanslon