Reputation: 442
I am wondering how I could check if a app is installed in chrome from a different chrome app. For example I have made app1 and app2 now I want to know if the user has app1 installed when he/she opens app2. Is this possible by some chrome api or is this not possible?
If I can not check if the user installed app1 then is their a work around of some sort?
I do have access to the chrome webstore if that matters.
What I want to do is provide some loyalty perks to those who install my other apps.
Upvotes: 4
Views: 703
Reputation: 77523
Since you wrote both apps, it's pretty simple by using External Messaging:
In app1 background script:
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
}
}
);
Upvotes: 6