Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: How to detect if an app embed block is activated

How to detect if an app embed block is activated

GuillaumeFg
Shopify Partner
4 0 3

Hi! 

 

I am currently developing a Shopify app which creates an App embed block the user can activate or not. 

 

I would like to display if the user has already activated the embed block in my app but I don't find any API for this purpose. 

 

Is there a way to perform this?

 

Thanks! 

Replies 9 (9)

Liam
Community Manager
3108 344 889

Hi GuillaumeFg,

 

I totally see how it would be helpful to reflect on your apps' UI when the embed block is active - I've connected with our internal devs to see if this is possible. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

GuillaumeFg
Shopify Partner
4 0 3

Hello @Liam, thank you very much !

Liam
Community Manager
3108 344 889

Hi again Guillaume,

 

The product team got back to me and while Shopify does not support this at the moment, we're aiming to allow this functionality in future API versions. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Hujjat
Shopify Partner
10 1 7

Hey @Liam & @GuillaumeFg !

Based on Shopify documentation, this should be possible here

I needed this for my app so I did some investigation on how I can detect if app embed is added by user or not. 

Here is what I have found using Remix. 

In your loader function, first find the active theme ID, then read the settings_data.json file. The app embed data will be saved in this file when user enable it. 

`

const activeTheme = await admin.rest.resources.Theme.find({
session: session,
role: 'main',
})

const settings_data = await admin.rest.resources.Asset.all({
session: session,
theme_id: activeTheme.id,
asset: {"key": "config/settings_data.json"},
});`

It will return a json format. 
`

{
"current": {
"sections": {
...
},
"content_for_index": [

],
"blocks": {
"17878678986028907411": {
"type": "shopify:\/\/apps\/faceforms-better-pop-ups\/blocks\/app-embed\/f2173231-e611-461d-884b-bd8e6cc2ded4",
"disabled": false,
"settings": {
...
}
}
}
}
}

`
You can look for your own app embed data if exist in this json file. 

"<block_unique_ID>": {
"type:": "<partner_name>:\/\/apps\/<app_name>\/blocks\/<block_name>\/<unique_ID>"

It it exist and enabled you can find out. 


I hope it helps other too 🙂 

Thank you!
Hujjat Asghari | Director at Codeinspire.io

We custom Shopify themes and apps


Our apps:


CodeInspire Accessibility Tool
Echo: Checkout Personalisation

farid-movsumov
Shopify Partner
100 6 32

Hey @Hujjat thanks for reply, I see asset api is marked as deprecated. Did you find any other way for verification?

farid-movsumov
Shopify Partner
100 6 32

After checking docs carefully I see reading is not a problem so we can use this method 🙏

appdev2023
Shopify Partner
21 2 3

great tips! shopify also has this guide for checking if an extension is installed:

https://shopify.dev/docs/apps/build/online-store/theme-app-extensions/configuration#detecting-app-bl...

mason225
Shopify Partner
16 0 4

look good. Thank you

Daniel-LiveChat
Shopify Partner
11 0 7

Hi @Liam is there any news on when Shopify plans to make this feature available via API? Knowing any timeframe would be a great help.