Facebook as an extension

Facebook as an extension

The more features we add to our extension system, the more extensions we can remove from the core engine and move out into a proper extension. This has several benefits, such as the engine becoming smaller for those that don’t use a certain extension. Or that the extension can be updated or improved upon by our users, depending on their needs.

In any case, it’s now time for our Facebook functionality to move out into a proper extension.
The planned release for this extension is in 1.2.154.

Transition

To retain your facebook support, you’ll need to add a dependency to your game.project, and that’s it.
The Lua module will work just as before.
(We’ll share the exact dependency link at the time of the release.)

In app purchases

We’ll move the iap module into a separate extension at a later stage.

Gameroom

We are also planning to move the Gameroom (Win32) extension out at a later stage.

Preliminary engine size saves

For Android, the classes.dex became ~610kb smaller.
For iOS, the engine became ~400kb smaller

30 Likes

Is the facebook extension already live? What is the url for it?

2 Likes

Probably this one https://github.com/defold/extension-facebook

5 Likes

It is scheduled to be officially released with version 1.2.156.
And yes, you can now already watch the code in the repository above.

Edit: it will be part of 1.2.157 (it misses the next release on monday)

5 Likes

I experienced with the new facebook extension and got it running with 1.2.156, but found a showstopper as I tried to add a simple “share to facebook-feed” button in my game.

I followed the examples to get publish permissions and made a call to facebook.show_dialog(dialog, param, callback) to test it out. When I tested it on iOS device, the app asked to launch facebook app, but when it started I got an error message:
"Invalid Scopes: publish_actions. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions "

I checked and it seems like facebook have removed “publish_actions” -permissions and have created a new Sharing products for this use case.

Facebook - Breaking Changes:
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#login-4-24
“The publish_actions permission has been removed. Apps that have already been approved for publish_actions can continue using the permission until August 1st, 2018. If you want to provide a way for your app users to share content to Facebook and Instagram beyond this date, we encourage you to use our Sharing products instead.”

What is the current de-facto way to create a sharing dialog in a game made with defold?

1 Like

Can you please share the code you used to login and to show the dialog?

1 Like

I followed the examples shown in here:
https://defold.github.io/extension-facebook/

My code:

local permissions = {"publish_actions"}

local function facebook_module_fb_share(self, result, error)
	if error then
		-- something did not go right...
	else
		-- do something sensible
	end
end

function facebook_module_login_with_publish()
	facebook.login_with_publish_permissions(permissions, facebook.AUDIENCE_FRIENDS, function(self, data)
		if (data.status == facebook.STATE_OPEN and data.error == nil) then
			print("Successfully logged into Facebook")
			pprint(facebook.permissions())

			local param = { link = "http://www.helmigames.com",picture="http://www.helmigames.com/wp-content/uploads/2017/01/helmiL.png" }
			facebook.show_dialog("feed", param, facebook_module_fb_share)
		else
			print("Failed to get permissions (" .. data.status .. ")")
			pprint(data)
		end
	end)
end

I simply require the facebook_module in a gui script and call the facebook_module_login_with_publish() function from a button click.

I tested the functionality by making a TestFlight release and using iOS device. Facebook app opens up as expected and asks if a connection to my game would be made by signing in with my facebook-account, but after accepting, the facebook app displays the error message I pasted above.

1 Like

Excellent. Thanks! I’ve created a ticket to track this: https://github.com/defold/extension-facebook/issues/4

@Mathias_Westerdahl has been working on this extension recently to update it and move it from the engine to an extension.

2 Likes

Yes, this is our old (internal) example. We’ve merely moved the code outside of the engine.
What permissions you wish to use is individual per app basis.

In the Facebook official documentation they’re using publish_to_groups: doc

And here is a list of their supported permissions

2 Likes

Thanks. I updated to use publish_to_groups -permissions and I no longer get the error messages. Using the show_dialog() function only seems to make a successful login to facebook but did not open the share to feed -dialog as I expected.

Is there something I’m missing to make a share to facebook feed working?

1 Like

Ok, good that it worked.

As for sharing, when pressing the “Share” button in the test project, you’ll invoke this code:

First:


then it will call this function:

3 Likes

We made small stability improvements for the facebook extension.
For the old facebook (4.x) extension the latest version is 1.6
https://github.com/defold/extension-facebook/archive/1.6.zip
For the new extension is 2.2.5:
https://github.com/defold/extension-facebook/archive/2.2.5.zip

3 Likes

The new release 2.2.7 of Facebook extension with Deferred Deep Linking functionality.

4 Likes

We just made a pre-release of a new version of the Facebook extension available for testing. The new version is based on the latest Facebook SDK version 5.9.0. It fixes login issues on iOS 13 (although this is also partially dependant on the upcoming Defold 1.2.164 release).

Please help us test the extension by adding the following two dependencies to your game.project file:

3 Likes

tried to build LyL with this dependencies and got:

list of all dependencies
2019-11-06_14-22-39

Seems, with FB 2.2.7 and extension-gps “master” the same. Previous workable build I’ve made with FB 1.4

Thanks. Could I please ask you to lock down more of your dependency versions? It’s very hard to promise any kind of stability when you depend on master.zip since that can change without notice. Please use these instead:

Ok, thanks, will try build with

Tried. The same result.

The bundle complete only if I remove admob extension. Seems admob (https://github.com/Lerg/extension-admob/) is compatible only with old Facebook extension :\

Let me try a couple of things here as well.

1 Like