SahJ

wait until my friend accepts (FBInstant)

Recommended Posts

When you selected a friend to create a new context.
How can I make that new context be created when my friend accepts?
    FBInstant.context.chooseAsync().then(function (result) {
        console.log(FBInstant.context.chooseAsync())
        window.FBInstant.updateAsync({
            action: 'CUSTOM',
            intent: 'REQUEST',
            cta: 'Play',
            template: "join_fight",
            image: base64Picture, //this should be source data of your share picture in 
            //base64! you can parse your picture to base64 use  
            //'https://www.base64-image.de'
            text: "X just invaded Y's village!",
            data: {
                myReplayData: "..."
            },
            strategy: 'IMMEDIATE',
            notification: 'NO_PUSH'
        }).then(function () {
            // closes the game after the update is posted.
            console.log("FBINSTANT Quit");
            FBInstant.context.createAsync(playerID)
            FBInstant.context.getPlayersAsync().then(function (result, error) {
                console.log(result);
            })
        });
        console.log(result)
    }).catch(function (err) {
        console.error(err);
    });

 

 

 

Captura.JPG

Share this post


Link to post
Share on other sites

Hi @SahJ, I do not understand your question.
When choosing a context with chooseAsync, the client will try to switch to that context and resolve. What do you mean by "when my friend accepts"?

console.log(FBInstant.context.chooseAsync()) -> why are you logging a method call?
Did you set base64Picture properly?

chooseAsync( )

Opens a context selection dialog for the player. If the player selects an available context, the client will attempt to switch into that context, and resolve if successful. Otherwise, if the player exits the menu or the client fails to switch into the new context, this function will reject.

Share this post


Link to post
Share on other sites
I'm sorry if my question is a little fuzzy, I'll try to detail it more.

When I invite my friend, chooseAsync () creates the context for me and my friend before my friend accepts, is there any way to create the context after my friend accepts, it's like doing a duel game, both of them play at the same time and who wins the highest score?
I mean, you can get a callback to know when my friend accepts

Captura1.JPG

Captura2.JPG

Captura3.JPG

Share this post


Link to post
Share on other sites

Hi @SahJ, I think I understand. You should use the field data in updateAsync when inviting from player A:

data: { myReplayData: '...' }

And then use FBInstant.getEntryPointData() with player B to retrieve the information that it was an invitation from player A.

Share this post


Link to post
Share on other sites

 

I was using this method and it works when player B enters the game with the frame that sends shareAsync () by messenger, up here well, but player A has the getEntryPointData () equal to null. My idea is to create a waiting room where player A waits for a certain amount of time for Player B to enter and skip the game.

 

Share this post


Link to post
Share on other sites

I have the same doubt. Is there any push notification system or the only way to notify the other user is through a new message in the chat window? What I wanted was to avoid closing the game after the user plays and reopen it again 

 

Share this post


Link to post
Share on other sites
On 2/28/2020 at 5:33 AM, Bonomi said:

I have the same doubt. Is there any push notification system or the only way to notify the other user is through a new message in the chat window? What I wanted was to avoid closing the game after the user plays and reopen it again 

 

did you know how to do it?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.