2013-08-01 40 views
2

我在擴展使用chrome.storage.sync同步在popup.html在一個文本輸入的數據同步。chrome.storage.sync不能跨瀏覽器和設備

進行存儲和正確本地還原數據,但是它不同步跨瀏覽器的數據。

每一個瀏覽器擴展都有自己的本地輸入數據可用。

下面的代碼是用來保存和恢復數據:

// Called when the user opens popup.html 
$(window).ready(
    function restore() { 
     var textarea = document.querySelector("#contacts"); 
     chrome.storage.sync.get('contacts', function(r) { 
      console.log("Contacts retrieved"); 
      var content = r["contacts"]; 
      textarea.value = content; 
     }); 
}); 

// Called when user saves his changes to the textarea 
$("#save-button").click(function() { 
     var textarea = document.querySelector("#contacts").value; 
     var save = {}; 
     save["contacts"] = textarea; 
     // Save data using the Chrome extension storage API. 
     chrome.storage.sync.set(save, function() { 
      console.log("Contacts saved"); 
     }); 
     $("#confirm").text("Contacts saved.").show().fadeOut(5000); 
}); 

在我manifest.json我將權限授予storage

"permissions": [ 
     "tabs", 
     "http://*/*", 
     "storage" 
    ] 
} 

什麼是Chrome同步不同步的原因跨瀏覽器和設備?

回答

3

是您的分機上傳到您的Chrome Web Store帳戶和發佈(或至少發佈到您的測試人員)?

跨計算機同步不適用於非網上商店擴展程序上次我檢查了,因此您必須將其放在Chrome網上應用店才能測試。

您還必須確保擴展程序根據chrome://settings/syncSetup進行檢查。

+1

嗨克里斯。是的,擴展可以在Chrome網上應用店[這裏]中找到(https://chrome.google.com/webstore/detail/sms-chrome/ndpcfnbbkogdnhdhgfmooinabiaakdnp/details),但只有德國的用戶,因爲核心功能只在工作德國。我從Webstore安裝了自己的擴展。所以不要在本地使用它。此外**擴展**在'chrome:// settings/syncSetup'下被選中。 – orschiro

+0

這很奇怪。由於某些原因,它現在正在工作。也許Chrome Sync在啓動跨設備和系統的同步過程之前需要一段時間? – orschiro

+5

轉到chrome:// sync,您將能夠看到同步是否正常工作以及正在同步的確切數據。 –