How do I check if a Chrome app is installed in another Chrome app?
I'm wondering how I can check if an app is installed in chrome from another chrome app. For example, I made app1 and app2, now I want to know if user app1 is set when he opens app2. Is this possible on some chrome apies, or is it not possible?
If I can't check if user app1 is installed then is this some kind of work?
I have access to the Chrome Web Store, if that matters.
What I want to do is provide some perks for those who install my other apps.
+3
source to share
1 answer
Since you've written both applications, it's pretty straightforward using External Messages :
In the app1 script frontend:
var app2id = "abcdefghijklmnoabcdefhijklmnoab2";
chrome.runtime.onMessageExternal.addListener(
// This should fire even if the app is not running, as long as it is
// included in the event page (background script)
function(request, sender, sendResponse) {
if(sender.id == app2id && request.areYouThere) sendResponse(true);
}
);
Somewhere in app2:
var app1id = "abcdefghijklmnoabcdefhijklmnoab1";
chrome.runtime.sendMessage(app1id, {areYouThere: true},
function(response) {
if(response) {
// Installed and responded
} else {
// Could not connect; not installed
}
}
);
+6
source to share