0

Is there a way to programmatically find app's id based on a name or some other criteria?

I have an extension that needs to exchange some data with an app. However, in order to send a message to the app I need to know the app's id. How can I get the id without any end user involvement?

I think I could hard-code the app's id into the extension but I'm not sure if this is the best option. In order to do that, I would always have to publish the app first, find its id, hard-code it into the extension, and then publish the extension.

Would this work? Are there better options to accomplish the above?

Thanks.

bdristan
  • 1,048
  • 1
  • 12
  • 36
  • 1
    You don't need to publish an app or extension to get a fixed id. See http://stackoverflow.com/questions/21497781/how-to-change-chrome-packaged-app-id-or-why-do-we-need-key-field-in-the-manifest/21500707#21500707 – rsanchez Jun 27 '15 at 17:46

1 Answers1

1

There is a way, but it's too heavy to be justified in a regular extension: chrome.management API. To be able to find out your app's ID with it, you'd have to make sure that the app be already installed by the user before the extension makes a query. In addition, such a permission may be hard to slip by more savvy users.

Hardcoding is your best option. The good news is, your app's ID will be fixed after the initial upload and will never change with subsequent uploads.

Xan
  • 74,770
  • 16
  • 179
  • 206
Sergey Shevchenko
  • 1,750
  • 14
  • 13
  • Incorrect, there is a way. `chrome.management` API (in an extension). However, I agree that hardcoding is the better option. P.S. I'll be happy to reverse the vote if you fix your answer. – Xan Jun 30 '15 at 09:25
  • Ah, yes, you are correct. I didn't think about this hammer. Will update the answer. – Sergey Shevchenko Jul 01 '15 at 17:06