Facebook as an extension

#1

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

25 Likes

#2

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

1 Like

#3

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

4 Likes

#4

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)

4 Likes

#5

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?

0 Likes

#6

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

0 Likes

#7

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.

0 Likes

#8

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.

1 Like

#9

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

1 Like

#10

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?

0 Likes

#11

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:

2 Likes

#12

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

2 Likes

#13

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

3 Likes

Facebook sdk deferred-deep-linking (SOLVED)