How do you handle reinstall of already installed App

Highlighted
New Member
5 0 0

Suppose a user already successfully installed your App but for some reason tried to install it again, what is the flow for handling this?

Example, My current flow is

1) User launches the App 

2) I check if I have a record for this user and if I have a permanent access token for this user.

a) If true, I load the App Home Page

b) If false, I take them to the OAuth authorize page where they install my app and they get redirected to step 1 above which then takes them again through all the way to step 2a where they then see the App Home Page.

 

The above works well when user installs the App, and later just tries to open the App. It also works if user uninstalls the App and tries to install it again.

 

I run into an issue when the app is already installed but user tries to install the App again. The above flow is executed up to step 2a where instead of the App Home Page being loaded in the iframe, it opens it outside of Shopify (i.e. on its own page). How do I fix this?

0 Likes
Highlighted
Trailblazer
173 13 28

I'm not sure I understand how these two scenarios are different - the link to "launch the app" is the same link for "install app" in the App Store isn't it? Or are you providing some alternate method or link to install your app?

That said, are you using app bridge? Have you tried using forceRedirect = true?

Also as an aside, it's probably better to not just check for presence of access token in your db, but to actually do a call to the shop endpoint using that access token to confirm it's still valid. 

0 Likes
Highlighted
New Member
5 0 0

@policenauts1 Thanks for the response.

1) I also thought the 2 scenarios were the same but apparently it is not. After the app is installed, if you go to a store's admin(a store that installed the app), and click on the App, everything works well (the flow I described works) and the App Home Page is opened within the iframe. If on the other hand the same store goes back to the install page and clicks on the App to install again, what I describe happens. 

 

2) No I'm not using App Bridge orforceRedirect = true. I will look into these. I should mention that my App is built in Python and I'm making straight python calls using the requests library

3) The documentation says an offline_mode gives you a permanent access_token which is why I just check for the presence of the token

0 Likes
Highlighted
Trailblazer
173 13 28

Gotcha, thanks for the additional details. I'm pretty sure forceRedirect = true will solve your issue - good luck and let me know if that doesn't work. 

Edit: Sorry, you said you're using python and not App Bridge - not sure I can help here then! 

0 Likes
Highlighted
New Member
5 0 0

I came up with a solution (it works for me at least).

I noticed there is a difference in the URL when you are trying to install over an existing installation versus when you simply open the installed app or install the first time.

If you are just trying to open the already installed App, the url includes the following parameters - session & locale. So if these parameters are not there, I know that the user is trying to install over an existing installation and I redirect them to my post-install url (the white listed urls). Since the system is the one doing the redirect, it opens in the iframe. I also have a failover client side code on the post-install redirect page. I have Javascript that checks if the page was opened outside an iframe and if so I force a redirect again to the post-install redirect url

0 Likes