Search code examples
facebookfacebook-iframeiframe-app

How to create "Welcome Page" for iframe apps?


I have a facebook app which runs in an iframe. When ever a new user comes in it asks for the required permission and lets the user login to use the app further.

Now I want to put welcome page where user can put in the "invite code" if the user is new else the current flow of asking the permission will follow.

So my question is every time a user comes in how can I show him a page before he actually goes through the permission dialogue box?

Let me know if the question makes sense to you guys else I ll explain further may be with steps.

-deepak


Solution

  • Use the Javascript SDK and call FB.getLoginStatus (https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/) to determine if the user is authenticated or not to your app.

    FB.getLoginStatus(function(response) {
      if (response.status === 'connected') {
        // the user is logged in and connected to your
        // app, and response.authResponse supplies
        // the user's ID, a valid access token, a signed
        // request, and the time the access token 
        // and signed request each expire
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;
      } else if (response.status === 'not_authorized') {
        // the user is logged in to Facebook, 
        //but not connected to the app
      } else {
        // the user isn't even logged in to Facebook.
      }
     });