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?
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.
@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
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.