Facebook Instant Games export workflow improvements


#1

Automatically include Bundle Configuration when exporting to Facebook Instant Games

Instant Games now require a file called “fbapp-config.json” in the root folder of the zipped file. More info here.

A minimal example file that works: fbapp-config.json.zip (704 Bytes)

Could a “facebook instant” checkbox be added to the “html5” settings in game.project, which includes this file? Ideally with an option to select the file, so it can be edited easily.

Add a “Facebook Instant Game” mode to liveupdate.settings

Facebook Instant games can now be hosted on Facebook servers. If the live update files could be exported, without being zipped, directly to the HTML5 export folder, they could be included in the uploaded bundle, and loaded on demand by the Defold game.

An example project that does just this: DefoldLiveUpdateForFacebookInstant.zip (457.0 KB)

It requires you to unzip the live update files from the “zip” folder and move them inside a “liveupdate” folder inside the HTML5 export folder. If the feature request was implemented, this would instead be entirely automated.


#2

Thanks for the suggestion, copied to our public issue tracker here: https://github.com/defold/editor2-issues/issues/2335


#3

Yay!


#4

No need. You should use the Bundle Resources field of game.project to have the build system automatically include it when bundling.

Put it in a structure like this one:

/bundle_resources/web/fbapp-config.json

And write bundle_resources in the Bundle Resources field of game.project.

I’ve added these instructions to the Instant Games readme: https://github.com/defold/extension-fbinstant/blob/master/README.md


#5

Yes, this could improve the workflow a bit.

Side-note: The base url thing we discussed should probably be included in the instant games API somehow so you don’t have to do this yourself. I’m thinking that maybe there should be a /fbinstant/baseurl.lua module that you can require. Something like this:

local M = {}

local get_baseurl_js = [[
	var hostname = window.location.hostname;
	var pathname = window.location.pathname;

	var r = /[^\/]*$/;
	var base_url = pathname.replace(r, '');
	return base_url;
]]

local base_url = nil

function M.get()
	if not base_url then
		base_url = html5.run(get_baseurl_js)
	end
	return base_url
end

return M

And use it like this:

local baseurl = require "fbinstant.baseurl"

http.request(base_url.get() .. "liveupdate/" .. message.resource_hash, "GET", function(self, id, response)
 ...

#6

I tried this and it works great!


#7

This looks fantastic, if you add it as a dependency addon I can test it.


#8

I’ve uploaded this to a branch: https://github.com/defold/extension-fbinstant/tree/baseurl

Please give it a try and let me know if it works as expected for you.


#9

Yes, works perfectly! I see you tidied up my code too, nice. :slight_smile: