Giter VIP home page Giter VIP logo

extension-fbinstant's Introduction

Instant Games

Facebook Instant Games for Defold

Instant Games is a new way for people to play games across Facebook platforms. Powered by HTML5 technology, it allows people to find and play games directly in the News Feed or Messenger conversations, on both desktops and mobile devices.

Manual, API and setup instructions is available on the official Defold site.

extension-fbinstant's People

Contributors

agulev avatar bnabz avatar britzl avatar ekharkunov avatar jhutchings1 avatar laltin avatar subsoap avatar totebo avatar vandutch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extension-fbinstant's Issues

Improve how supported APIs can be checked

Returning a set makes it easier to check if a certain function is supported or not:

local supported_apis = fbinstant.get_supported_apis()
if supported_apis["getInterstitialAdAsync"] then
   -- load/show interstitial
end

Or maybe even utility functions such as fbinstant.is_ads_supported() would be event better?

Dummy API

There's a version of the API which returns dummy results, not require connection to Facebook for testing, may be useful to support somehow

HTML5 localhost check

Something like this for mock.lua

local info = sys.get_sys_info()

if info.system_name == "HTML5" then
	local domain = html5.run("window.location.hostname")
	if domain == "localhost" then
		fbinstant = nil
	end
end


if fbinstant then return end
fbinstant = {
	mock = true
}

...

fbinstant.set_leaderboard_score fails silently

Too many leaderboard requests can produce an error like this, causing the callback to never fire:

FBInstant_PlatformSetLeaderboardScoreAsync - error: Game called too many leaderboard APIs too quickly. Reduce the rate of requests in order to avoid being rate-limited.

Add FBInstant.switchGameAsync

It's still in private beta? Could test and see if it works anyway. Main thing is all of the appids need to belong to the same business on Facebook API.

fbinstant.get_player_stats() should get multiple stats

is fbinstant.get_player_stats() work only with one value per time?

Original example is:

FBInstant.player
  .getStatsAsync(['level', 'zombiesSlain'])
  .then(function(stats)) {
    console.log('stats are loaded');
    var level = data['level'];
    var zombiesSlain = data['zombiesSlain'];
  });

Ads not loading more than once

Iโ€™m trying to load Facebook instant game ads several times using two placement IDs using bellow functionality,

-- Preload ad unit
function load_ad_unit(ad_unit_id)
    print("loading ad unit...")
    fbinstant.load_interstitial_ad(
        ad_unit_id,
        function(self, success)
            if success then
                print("Ad unit successfully loaded ")
            else
                print("Ad unit doesn't loaded ", ad_unit_id)
            end
        end
    )
end

-- Show ad unit
function show_ad_unit(ad_unit_id)
    fbinstant.show_interstitial_ad(
        ad_unit_id,
        function(self, success)
            if success then
                print("Ad unit successfully opened ", ad_unit_id)
                -- * I put this here because `show_interstitial_ad`
                -- handles removing the ad instance
                load_ad_unit(ad_unit_id)
            else
                print("Ad unit doesn't opened ", ad_unit_id)
            end
        end
    )
end

function on_message(self, message_id, message, sender)
    if message_id == hash("NEW_GAME") then
        load_ad_unit("<ad_unit_id>")
    elseif message_id == hash("ON_PRESS") then
        show_ad_unit("<ad_unit_id>")
    end
end

But this only works once at the beginning of the game when I press a button. For the second time, it won't work. Below are errors that occur in most situations,

> FBInstant_PlatformShowInterstitialAdAsync - unable to find ad. Did you load it?
> FBInstant_PlatformLoadInterstitialAdAsync - error a {code: "ADS_NO_FILL", message: "No fill"}
> FBInstant_PlatformLoadInterstitialAdAsync - error a {code: "ADS_TOO_MANY_INSTANCES", message: "Too many ad instances"}

This issue is from the forum: https://forum.defold.com/t/facebook-instant-games-ads-not-loading-more-than-once/43392

Send screenshot/image with the context update

The payload passed to fbinstant.update() must include an image. This is typically a screenshot or some other visuals that show the current progress of the game.

Add a function to properly base64 encode and format the image value.

Look into Canvas.toDataURL and also dig into the Defold-Screenshot extension on HTML5.

Blank/empty image:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC"

Accept Lua tables as arguments and serialize to json in c land

Currently the communication from Lua to JS via C requires complex data structures (Lua tables) to be serialized to JSON in Lua before passed on as a string to the extension and deserialized again in Javascript. The same process but in reverse goes for complex responses from Javascript back to Lua.

The preferred solution is to pass Lua tables to C and let the C code serialize to JSON. Currently there's no support for serializing a Lua table to JSON from C.

Task: Evaluation of JSON parsers in C. Integrate with extension.

Perhaps Lua table to JSON and back again should be part of the DMSDK?

Chat bot example

Testing new chat bots should work again, can add to example at some point for XOXO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.