Leaving code in the theme after uninstalling the app

Solved
dmitry_pokidov
Tourist
7 0 0

Hi there,

 

I started developing a public app. It's my first one and I'm worry about finishing it and then get rejected on review process.

 

The app is adding a new section to the current merchant's theme. I could not find a way to delete those sections when merchant decides to uninstall the app. I created "Delete Sections" button in the app with a text above saying "Please delete sections prior to uninstalling the app", but I'm not sure if it's ok.

 

There are 2 questions that I have:

  • Is there a way to clean up theme assets before uninstalling the app (did I miss it in documentation?)?
  • Could it be a problem during review process?

Also, I know about script tags, but I can't use them cause one of the feature of the app is high performance. 

 

Thank you.

0 Likes
Vellir
Shopify Partner
132 29 33

Hey  dmitry_pokidov,

 

One way to approach this is to subscribe to the app/uninstalled webhook and use the assets API to delete/update any custom code left behind. 

- Yes, we build Shopify Apps. Hit me with your idea: https://vellir.tech
- Let customers preview your products and easily add them to cart with Peek Mode
- Add free, good looking social share icons with built-in analytics to your store with Share Lab
- Manage your new arrivals with Newr
0 Likes
dmitry_pokidov
Tourist
7 0 0

Thanks for the reply! My understanding was that when uninstalled hook is executed the access token is not valid anymore, isn't it true?

0 Likes
JoesIdeas
Shopify Expert
1188 104 285

This is an accepted solution.

Since you can't access the shop after uninstalling, another approach would be to send a farewell email with uninstallation instructions.

 

I see a lot of stores with extra theme code from uninstalled apps, so I bet they'd appreciate that email (and side bonus you might also get some feedback why they uninstalled).

Founder of Speed Boostr (Shopify optimization experts, theme customization, custom app development).
Creator of Shopify Analyzer (first performance analysis tool for Shopify sites, free for the Shopify community).
Creator of Order Automator (auto tag orders and customers + auto fulfill orders + email notifications).
Creator of Theme Scientist (A/B testing app) and Tip Jar (add a tip button to your store).
dmitry_pokidov
Tourist
7 0 0

@JoesIdeas wrote:

Since you can't access the shop after uninstalling, another approach would be to send a farewell email with uninstallation instructions.

 

I see a lot of stores with extra theme code from uninstalled apps, so I bet they'd appreciate that email (and side bonus you might also get some feedback why they uninstalled).


Thanks, farewell email is a great idea! 

 

I'll probably do a button "Delete Theme Files" and farewell message. Thanks a lot @JoesIdeas for your help!

0 Likes
JoesIdeas
Shopify Expert
1188 104 285

That's a nice move having the "delete theme files" option before they uninstall. Could essentially function as an "Uninstall" button that removes the files, then says to complete uninstall delete the app from your Apps section.

 

I like this idea of thinking about the user's journey after they've moved on, that's respectable 👍

Founder of Speed Boostr (Shopify optimization experts, theme customization, custom app development).
Creator of Shopify Analyzer (first performance analysis tool for Shopify sites, free for the Shopify community).
Creator of Order Automator (auto tag orders and customers + auto fulfill orders + email notifications).
Creator of Theme Scientist (A/B testing app) and Tip Jar (add a tip button to your store).
kavishatalsania
New Member
3 0 0

@dmitry_pokidov How can you remove code from "Delete theme files" button? Don't you need access token for that also? Right now only way is to give instruction. Correct? 

0 Likes
dmitry_pokidov
Tourist
7 0 0

So, what we've done is put a button on the app saying "Clean up" and instructions. It's deleting theme files and we have token cause the app is still installed. You could see an example in our app - https://app.shopify.com/hero-banner.

0 Likes
kavishatalsania
New Member
3 0 0

Understood. Thanks for the reply!

0 Likes
darrynten
Shopify Partner
11 0 3

One way to approach this is to subscribe to the app/uninstalled webhook and use the assets API to delete/update any custom code left behind. 

As crazy as it sounds, this isn't possible.

Shopify do not let you remove theme code after the user has clicked the trash can icon on their app list. It's the leading cause of 1-star reviews.

Why we're not allowed to clean up remains a mystery, I've asked so many times.

To me it seems very straightforward to increase the blacklist timeout by 10 seconds for apps that have theme.write permission so they can clean up after uninstall - not sure why this is still an issue six years after it was first reported on this forum.

 

@darrynten