Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for App Bridge 2 #1290

Closed
asecondwill opened this issue Jun 29, 2021 · 5 comments
Closed

Instructions for App Bridge 2 #1290

asecondwill opened this issue Jun 29, 2021 · 5 comments

Comments

@asecondwill
Copy link

The app review process is now asking for app bridge 2. I've followed the JWT example this month and somehow ended up with app bridge 1. I see there is a pull request merged for App Bridge 2 supprt. What do we need to do to switch over?

@asecondwill
Copy link
Author

#1241
Shopify/turbolinks-jwt-sample-app#41

@kirillplatonov
Copy link
Contributor

You can use this sample app: https://github.com/kirillplatonov/shopify-hotwire-sample
It includes JWT integration with Turbo and AppBridge 2.

@kgorshkov
Copy link

I have a published app running with the following gems:

rails 5.2.5
shopify_app 17.2.1

I updated all copies of embedded_app.html.erb with the following:

<script src="https://unpkg.com/@shopify/app-bridge@2"></script>

<%= content_tag(:div, nil, id: 'shopify-app-init', data: {
  api_key: ShopifyApp.configuration.api_key,
  shop_origin: ("https://#{ @current_shopify_session.domain }" if @current_shopify_session),
  shop_origin: @shop_origin || (@current_shopify_session.domain if @current_shopify_session),
  host: @host,
  forceRedirect: true,
  debug: Rails.env.development?
} ) %>

Everything functions fine except that after installation and recurring charge approval in production, there is a redirect to the app url, so the app is not loading as an Embedded app in Shopify admin. The app loads fine when accessed via the Apps list. I rolled back production for now to Embedded App SDK which does not have the same post-install redirect issue.

This is a major issue preventing my switch to App Bridge 2.0, and it's not clear to me if this is something I need to fix in my code or if this is an open issue with shopify_app. I do see kirillplatonov's demo app, however it is a rails 6 example and I'm not sure that diving through the code will yield a solution.

I tried adding ' forceRedirect: true' as seen above but that doesn't help, and I've tried a few other things. This appears to be a common issue and there are several other developers that have run into it as seen in this unanswered Shopify forum post:

https://community.shopify.com/c/Shopify-APIs-and-SDKs/Embedded-app-getting-redirected-to-app-url-on-install-embeds/td-p/805310

The deadline to switch to App Bridge 2.0 is 12/31/21 and it seems that the shopify_app gem needs an update and some migration instructions.

Thanks,

KG

@kirillplatonov
Copy link
Contributor

kirillplatonov commented Sep 2, 2021

@kgorshkov try adding forceRedirect: true to createApp call in shopify_app.js file. Like this:

window.app = createApp({
  apiKey: data.apiKey,
  host: data.host,
  forceRedirect: true,
});

@nelsonwittwer
Copy link
Contributor

Seems like we found a solution to upgrade :) thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants