Facebook小游戲?qū)涌偨Y(jié)

懵新對(duì)接時(shí)facebook小游戲文檔按要求跑流程。賬號(hào)每次都是在一兩天被莫名其妙的上傳照片,驗(yàn)證收不到等問(wèn)題。所有問(wèn)題都是: vpn的IP不固定,或者不穩(wěn)定造成的!前期一定要把賬號(hào)穩(wěn)定。?。。。?br> 一.代碼邏輯:
1.初始化(后面所有接口都在完成后操作)

FBInstant.initializeAsync().then(function () {});

2.平臺(tái)區(qū)分

FBInstant.getPlatform() /**WEB/IOS/ANDROID/MOBILE_WEB*/

3.進(jìn)度

FBInstant.setLoadingProgress(progress);

4.用戶(hù)信息

FBInstant.startGameAsync().then(function () {
            this.contextId = FBInstant.context.getID();
            this.contextType = FBInstant.context.getType();
            this.playerName = FBInstant.player.getName();
            this.playerPic = FBInstant.player.getPhoto();
            this.playerId = FBInstant.player.getID();
        });

5.分享

    FBInstant.shareAsync({
        intent: 'REQUEST',
        image: base64,
        text: "Come and play together",
        data: shareData.data,/**分享額外數(shù)據(jù)*/
    }).then(function () {
    });

6.base64處理

Base64: function (src, callback) {
        let img = new Image();
        img.crossOrigin = 'Anonymous';
        img.onload = function () {
            let canvas = document.createElement('CANVAS');
            canvas.height = 533;
            canvas.width = 960;
            canvas.getContext('2d').drawImage(this, 0, 0, 960, 533);
            return callback(canvas.toDataURL());
        };
        img.src = src;
    }

7.廣告(插屏,視頻基本邏輯差不多) --->下面以插屏廣告為例子

/**AdPreloadArray 存放廣告Id數(shù)組 AdIdArray存放預(yù)加載實(shí)例化*/
for (var i = 0; i < AdPreloadArray.length; i++) {
      this.interstitialAd(AdPreloadArray[i], i);
    }
    interstitialAd: function (adId, i) {
        FBInstant.getInterstitialAdAsync(adId).then(function (interstitial) {
            AdIdArray.push(interstitial);
        }).then(function () {
        }).catch(function (error) {
        });

預(yù)加載

preload: function (posId, callback) {
        console.log("posId===", posId, AdIdArray);
        if (AdIdArray.length != 0)
            AdIdArray[posId].loadAsync().then(function () {
                return callback(true, "Interstitial ready");
            }).catch(function (error) {
                return callback(false, error.message);
            });
    },

顯示

ShowAd: function (posId, callback) {
    if (AdIdArray.length != 0)
        AdIdArray[posId].showAsync().then(function () {
              return callback(true, "Interstitial watched!");
            }).catch(function (error) {
               return callback(false, error.message);
            });
    }

8.上報(bào)信息

FBInstant.logEvent(eventName, value, parameters);

9.好友一起耍

var player = FBInstant.player.getName();
    FBInstant.context.chooseAsync().then(function () {
    FBInstant.updateAsync({
             action: "CUSTOM",
             cta: "Join Now",
             template: "play_with_friends",
             text: { default: player + "invited you to play Fantasy Clash" },
             image:base64,})
            })
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 后臺(tái)配置-Facebook小游戲 1.簡(jiǎn)介 本文檔主要是說(shuō)明如何在Facebook配置Facebook小游戲所用到...
    af49bf676d38閱讀 2,763評(píng)論 0 0
  • 管理究竟是什么東西?如果照本宣科的說(shuō),那么管理就是為了完成個(gè)人無(wú)法完成的目標(biāo),結(jié)合資源,運(yùn)用管理職能的社會(huì)活...
    雙雙_19e1閱讀 1,282評(píng)論 1 0
  • 當(dāng)大雪封山 我愿做去一個(gè)潛水艇司機(jī) 在她柔軟的肉體里 肆意翻滾,咆哮 去放縱鋼鐵一般的意志 除非,它被擱淺 看雪白...
    燦7閱讀 588評(píng)論 2 5
  • 當(dāng)?shù)仄骄€(xiàn)上的第一縷陽(yáng)光升起的時(shí)候,標(biāo)志著新的一天的到來(lái)。當(dāng)山頭落日最后一抹斜暉消失的那一剎那,明天即將又要開(kāi)始。大...
    夏日娃閱讀 345評(píng)論 1 1

友情鏈接更多精彩內(nèi)容