Games on Facebook now offers you a way to upload your games' client code directly to Facebook instead of hosting it on your own or other third-party servers. It's a new, free, and easy way to reach millions of players using the same fast and reliable infrastructure that powers Facebook photos and videos.
Hosted games will continue to use iframes to deliver the experience, but you will no longer need to specify a Facebook Web Games URL to use them. Simply upload your assets, and we will take care of publishing and updating your Facebook Web Games URL internally.
Learn more about how Facebook games use iframes with external hosting here.
In your App Dashboard, under Products, there is a new tab titled Web Hosting. Note that your app needs to be categorized as Games in order to add this product.
Under this tab, you can find everything you need for uploading and managing your game assets. Currently, we support common web assets such as html, css, and image files including these additional highlights:
Please note the following restrictions on these uploaded apps:
From the Hosting tab, select a Hosting Type appropriate for your type of application:
Currently only two types of applications are supported: HTML5 web applications, and Unity's WebGL. The separate Unity WebGL type enables some additional target-specific optimizations and features that do not affect regular web applications.
HTML5 applications are served as a zip archive, with the same constraints as Unity's WebGL. Loading the game invokes the
index.html in the root of the zip archive.
It's very important that the generated
index.html file is located at the root of the zip file, as this is the only place we can launch the content. All other URLs need to be a relative path.
Resources may be placed anywhere in the directory structure, as long as they are referenced relative to
index.html. For example, the following file:
must be referenced as:
While the query parameter
The WebGL build target from Unity can be zipped up and uploaded directly.
It's very important that the generated
index.html file is located at the root of the zip file, as this is the only place that content will launch from. All URLs should be a relative path.
With Unity 5.1, this is a zip archive containing the following:
You may handle user login with the Unity SDK. The Facebook for Unity SDK is supported in the WebGL build target. Read more about the Facebook for Unity SDK.
Newly uploaded assets are shown with a Processing status. This process take 15-90 seconds to prepare and scan the assets. After this finishes, your asset will transition to a Standby status.
In order to use the assets in your application, you can select the Push to production button for the uploaded asset row.
Selecting Push to production will update the asset to the Production status. Test applications' assets will be shown with a Testing status.
If this is the first time your application will use hosting, you must also enable Simple Application Hosting from your application's Settings tab.
This will switch your application from using a Facebook Web Games URL to using the assets uploaded on the Web Hosting tab. You may disable Hosting and switch back to your Facebook Web Games URL at any time by toggling this option off.
At this stage of development, developers and other account roles for your game will be able to play and test your game.
However, before general players can access your hosted game, it must first be approved for App Center listing. If your game is already listed in App Center, you do not need to perform this step.
Start your game review submission through the App Center tab in the App Dashboard. More information here.
Assets for your game hosted via Web Hosting should only be accessible through Facebook. You may not link to these assets from external sites or applications.
When using an HTML5 Application with embedded flash assets, the default local storage path for these assets will change between version updates. You can avoid this by updating your SharedObject.getLocal() calls to include a non-null localPath.