Difference between revisions of "FBInstant"

From GiderosMobile
(new FBInstant page + new GIDEROSOBJ:FBInstant)
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<languages />
 
<languages />
 
 
<!-- GIDEROSOBJ:FBInstant -->
 
<!-- GIDEROSOBJ:FBInstant -->
 
 
'''<translate>Supported platforms</translate>:''' [[File:Platform html5.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform html5.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2018.3<br/>
 
'''<translate>Available since</translate>:''' Gideros 2018.3<br/>
  
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
You need to do two things to target Facebook Instant Games:
+
Facebook Instant Games Initialisation and Core.
# Tick the Facebook Instant Game tickbox when exporting to HTML5, you can also specify the percentage indicator that the game will show it has loaded before you take control.
 
# Require the FBInstant library code, see the example below.
 
 
 
  
You can upload, debug and test your game by creating a player and uploading to Facebook servers as a game. The player will interact with the Gideros Studio similar to any other player.
+
It is very important that only the following API calls are made before startGameAsync has resolved:
 
 
 
 
The only restriction with the player is that it only works on the computer viewing the html5 game (localhost) - this would normally rule out actual phones but there is a workaround for Android:
 
# Connect your Android phone to your computer using ADB.
 
# Type in this command in a command console shell (Windows) or terminal (Mac): '''adb reverse tcp:15001 tcp:15001'''
 
# The Android device now will see the Gideros Studio when testing the game when a player is launched from within Facebook Messenger.
 
 
 
 
 
Please refer to the https://developers.facebook.com/docs/games/instant-games/getting-started/quickstart original Facebook documentation for more information about testing and uploading.
 
 
 
 
 
Please note that the official Facebook documentation mentions having to wait for initializeAsync, with Gideros this has already been done for you before your game starts.
 
 
 
 
 
It is very important that only the following API calls are made before startGameAsync has resolved:<br/>
 
FBInstant.getSDKVersion()<br/>
 
FBInstant.initializeAsync()<br/>
 
FBInstant.getPlatform()<br/>
 
FBInstant.setLoadingProgress()<br/>
 
FBInstant.getSupportedAPIs()<br/>
 
FBInstant.quit()<br/>
 
FBInstant.onPause()<br/>
 
FBInstant.player.getID()
 
  
 +
*'''FBInstant.getSDKVersion()'''<br/>
 +
*'''FBInstant.initializeAsync()'''<br/>
 +
*'''FBInstant.getPlatform()'''<br/>
 +
*'''FBInstant.setLoadingProgress()'''<br/>
 +
*'''FBInstant.getSupportedAPIs()'''<br/>
 +
*'''FBInstant.quit()'''<br/>
 +
*'''FBInstant.onPause()'''<br/>
 +
*'''FBInstant.player.getID()'''<br/>
  
 
To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true.
 
To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true.
Line 43: Line 23:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Initialisation and removal of the Facebook loading progress indicator.'''
 
'''Initialisation and removal of the Facebook loading progress indicator.'''
<br/>
+
<syntaxhighlight lang="lua">  
 
 
<source lang="lua">  
 
 
pcall(function() FBInstant=require "FBInstant" end)
 
pcall(function() FBInstant=require "FBInstant" end)
 
if FBInstant then
 
if FBInstant then
Line 55: Line 33:
 
print("FBInstant not loaded")
 
print("FBInstant not loaded")
 
end
 
end
</source>
+
</syntaxhighlight>
  
 
{|-
 
{|-
Line 87: Line 65:
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}
 +
 +
{{Facebook Instant Games}}

Latest revision as of 15:26, 13 July 2023


Supported platforms: Platform html5.png
Available since: Gideros 2018.3

Description

Facebook Instant Games Initialisation and Core.

It is very important that only the following API calls are made before startGameAsync has resolved:

  • FBInstant.getSDKVersion()
  • FBInstant.initializeAsync()
  • FBInstant.getPlatform()
  • FBInstant.setLoadingProgress()
  • FBInstant.getSupportedAPIs()
  • FBInstant.quit()
  • FBInstant.onPause()
  • FBInstant.player.getID()

To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true.

Examples

Initialisation and removal of the Facebook loading progress indicator.

 
pcall(function() FBInstant=require "FBInstant" end)
if FBInstant then
	FBInstant.startGameAsync(function() 
		print("Loading screen removed")
		FBInstantAPI=true
	end)
else
	print("FBInstant not loaded")
end

Methods

FBInstant.canCreateShortcutAsync Returns whether or not the user is eligible to have shortcut creation requested.
FBInstant.checkCanPlayerMatchAsync Checks if the current player is eligible for the matchPlayerAsync API.
FBInstant.createShortcutAsync Prompts the user to create a shortcut to the game.
FBInstant.getEntryPointAsync Returns the entry point that the game was launched from.
FBInstant.getEntryPointData Returns any data object associated with the entry point that the game was launched from.
FBInstant.getInterstitialAdAsync Attempt to create an instance of interstitial ad.
FBInstant.getLeaderboardAsync Fetch a specific leaderboard belonging to this Instant Game.
FBInstant.getLocale The current locale.
FBInstant.getPlatform The platform on which the game is currently running.
FBInstant.getRewardedVideoAsync Attempt to create an instance of rewarded video.
FBInstant.getSDKVersion The string representation of this SDK version.
FBInstant.getSupportedAPIs Provides a list of API functions that are supported by the client.
FBInstant.logEvent Log an app event with FB Analytics.
FBInstant.matchPlayerAsync Attempts to match the current player with other users looking for people to play with.
FBInstant.onPause Set a callback to be fired when a pause event is triggered.
FBInstant.quit Quits the game.
FBInstant.setLoadingProgress Report the game's initial loading progress.
FBInstant.setSessionData Sets the data associated with the individual gameplay session for the current context.
FBInstant.shareAsync This invokes a dialog to let the user share specified content.
FBInstant.startGameAsync This indicates that the game has finished initial loading and is ready to start.
FBInstant.switchGameAsync Request that the client switch to a different Instant Game.
FBInstant.updateAsync Informs Facebook of an update that occurred in the game.

Events

Constants