I'm trying to build a Shopify embedded app using Google Apps Scripts and am having trouble getting the library to provide any kind of response. I have built an app with App Bridge before using regular JS / HTML / CSS, but I am wondering if there is something that is preventing it from working with Apps Scripts creating the HTML output.
function doGet(e) {
// I was experimenting with this and it throws a 'window not defined' error
// eval(UrlFetch('https://unpkg.com/@shopify/[email protected]/umd/index.js').getContentText());
return HtmlService.createTemplateFromFile('Page')
.evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
And in my Page.html I am including Javascript.html like:
<?!= include('JavaScript'); ?>
In Javascript.html I try to initialize the app but the App Bridge library doesn't respond at all in the console. I've also tried to render a ResourcePicker, for example, and nothing happens.
<script src="https://unpkg.com/@shopify/[email protected]/umd/index.js"></script>
<script>
var AppBridge = window['app-bridge'];
var actions = AppBridge.actions;
var createApp = AppBridge.default;
var app = createApp({
apiKey: {my api key},
shopOrigin: {shopOrigin}
});
...