It looks like you’re including App Bridge via a <script> tag pointing to a CDN-hosted copy of the library. Specifically, it looks like you’re using using @shopify/app-bridge@2. To start using App Bridge 3.0, you should be able to replace the 2 with 3.
In the code snippet you included, I noticed that App Bridge is initialized with the shop and shopOrigin parameters. This should change, and you should initialize App Bridge with a host parameter instead (as shown here).
I didn’t made any changes as of now (still in App bridge 2 as shown in my question). I just opened our app from the Apps and sales channels Settings for one of a Shopify store.
On clicking our app, it got redirected to a link like
I didn’t made any changes as of now (still in App bridge 2 as shown in my question)
But you will need to make changes in order for your app to be compatible with the changes that are coming to the Shopify platform (moving to the admin.shopify.com domain).
So where can I get the host from?
The host is passed as a query-string parameter, when Shopify loads your app.
I am not a PHP developer, but I think that this will do the trick:
<?php echo $_GET['host']; ?>
As mentioned above, you should avoid initializing App-Bridge with shop and shopOrigin, and specify the host instead (as shown in the docs).
As for
Is the host different each time the client loads the app? Or is it same till they uninstall the app?
Shops are being migrated to the new domain gradually, and there is no way for your app to know in advance which (of the two domains) a shop will be running on. That’s why Shopify provides the host value when it loads your app.
Final note: The host query-string parameter will only be available when Shopify first loads your app. If your app is NOT a single-page app, you’ll need to persist the host on the server (e.g. in the session) in order to inject it on subsequent page loads.