1

I tried all solutions in this question

Check whether user has a Chrome extension installed

what I did:

1- I added background js file and in manifest I added the following

 "background": { "scripts": ["js/background.js"], "persistent": true }, "permissions": [ "https://*.mydomain.com/*" ], 

in background.js I added

chrome.runtime.onMessageExternal.addListener(function(msg, sender, sendResponse) { if ((msg.action == "id") && (msg.value == id)) { sendResponse({id : id}); } }); 

and in my website I added this code

<script> var id = "madbfblbpcoiddlankhkdbagjeemnlof"; chrome.runtime.sendMessage(id, {action: "id", value : id}, function(response) { if(response && (response.id == id)) //extension installed { console.log(response); } else //extension not installed { console.log("Please consider installig extension"); } }); </script> 

and I always get Please consider installig extension

How can I fix this issue ??

0

1 Answer 1

3

Define your id at the start of your background.js like so: var id = chrome.runtime.id;.

Also you need to add your site to the externally_connectable instead of the permissions in the manifest.json as:

"externally_connectable": { "matches": ["https://*.mydomain.com/*"] } 
Sign up to request clarification or add additional context in comments.

1 Comment

It worked like a charm I didn't know about externally_connectable . thank you for your help you saved me

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.