简体   繁体   中英

Facebook instant game login with JS SDK

I am trying to upload my game made with React to Facebook Instant games. I have facebook login implemented with Facebook JS SDK. But facebook instant game runs inside a sandboxed iframe which blocks any popups and I cannot run FB.login(). In instant games docs it says that FB.login should work and it should open a popup in 'async' mode. But it doesn't. Login popup gets blocked and I get the following error:

Blocked opening ... in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.

You are looking for the wrong documentation, which leads to Legacy Web games. You need to refer to the Facebook Instant Game SDK to get the user information inside a FB Instant Game. Most importantly FB Instant games don't allow to use of the Facebook Graph API within the FB Instant Game. Although the Graph API offers more capabilities like getting the user gender , the Facebook Instant Game SDK only exposes a limited number of data for developers. The Facebook Login for the Web with the JavaScript SDK is an OAuth login that cannot be used inside a FB Instant Game.

FYI: Facebook Instant GAme SDK v7.0 doesn't provide all the user information about the user. It only provides the following data

  • Display Name

    var playerName = FBInstant.player.getName()

  • Profile Picture

    var playerImage = new Image(); playerImage.crossOrigin = 'anonymous'; playerImage.src = FBInstant.player.getPhoto();

You can only use the above information in your FB instant games.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM