Facebook login conflict

Hi, I just want to ask if anybody knows how to solve the problem on signing-in on facebook, I have been trying to solve this for 5 days already but couldn’t really get it. Currently, the device I am using has a facebook app installed in it. What I have encountered is that if the installed facebook app is not logged in, whenever I want to post something on facebook from the app that I am creating, what it does is that it asks the user to log-in to the installed facebook app, after signing-in it goes back to app but prompts an error, then if you click it again, it then goes to the facebook popup and asks the user to sign in again but this time the showDialog that I wanted to show now works. Is it possible that it will automatically go to the facebook popup without having any conflicts with the installed facebook app if it is not signed in? If possible, how?

Hey, @czartezadev, is your app for Android devices, and if so, what Corona daily build version are you using?  Seeing that you are Starter, maybe you don’t have the access to the most recent daily build… hmmm… the conflict between FB native app and FB integrated Corona app have been resolved as of daily build 1179.  

If you don’t have the access to the latest daily build, and you are working on Android version of your app, you’ll have to implement workaround.  In the following thread, Andrew @aukStudios explains in great detail about this issue, and it should help you code the necessary workaround (if you can’t use the daily build 1179 or later):

http://forums.coronalabs.com/topic/37679-facebook-frustrations/

Naomi

Thanks Naomi.  If @czartezadev is using the latest public build, which is build 1137, I think the key login challenge on Android that I described in that post wouldn’t be a problem, since that challenge didn’t start until build 1141.

But, it sounds like @czartezadev is describing a different (potential) issue, one that I haven’t looked it.  @czartezadev is describing a situation where the Facebook app is installed on the device, but it’s not signed in.

@czartezadev, some more information about what you’re seeing would be helpful:

  • After the user signs into the Facebook app, and then it goes back to your app, you said it prompts an error.  What is the error?  Also, what info is passed to your Facebook listener function?

  • Are you calling facebook.login() at some point?

  • What API are you using to post to Facebook?  It sounds like you’re using facebook.showDialog(), probably facebook.showDialog(“feed”).  Is that right?

  • It would help if you posted snippets of your Facebook code so we had a better sense of what you’re doing

  • Andrew

That may be the reason, my daily build is 1135. Thank you, I’ll read the post you linked :slight_smile:

@aukStudios Hi, as for the 1st question, the errors prompts very quickly so I did not have a chance to copy it, but what I have understood is that ‘Login failed, contact app developer to report it to facebook’ something like that and at the end it says facebook error #xxxxx. For the 2nd question, yes, I have been calling facebook.login everytime the user taps the button from my app. For the 3rd question, I have been using the external named GGFacebook which I found on github, it works almost the same facebook API in corona. 

Actually, my problem is that if the installed facebook app is not logged in yet, it goes to the log in page of the installed facebook app then after signing in, it prompts an error. But if the installed facebook app is logged in already, the pop-up works just fine. What happens is that the user have to sign-in twice.

Below is my code:

local toast = require “toast”

local GGFacebook = require “GGFacebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local post = display.newText(“Post message”, 0, 0, native.systemFontBold, 50)

post.x = display.contentWidth/2

post.y = display.contentHeight/2 + 100

post.alpha = 0

local facebook = GGFacebook:new(“xxxxxxxxxxx”) --appID

local function login()

    facebook = GGFacebook:new(“xxxxxxxxxxx”)

    toast.new(“Please wait”, 2000)

    facebook:login()

    facebook:makePost( “https://play.google.com/”, “http://s12.postimg.org/7f47yzq8p/Icon_72.png”, “Rubberducky”, “Android game”, “I got 100 in 120 seconds!”)

end

postText:addEventListener(“tap”, postFunction)

Well, I don’t use GGFacebook, so I may not be able to help you there.

But glancing at your code, a few things strike me:

  • It seems strange that you would call facebook:login() every time the button is pressed, as opposed to just the first time
  • It may not work to call facebook:login() and then, on the next line, call facebook:makePost().  The login process is asynchronous, so you may have to call facebook:makePost() within the callback listener to the login.  (It’s possible that’s not necessary, but my guess is that it is)

Why aren’t you able to copy/paste the exact error you’re seeing?  That would definitely be helpful.  When you say it prompts very quickly, what do you mean exactly?  Does the error show as a popup or something on the device itself?  Or does it show in the terminal output?

  • Andrew

@aukStudios actually, GGFacebook’s makePost and showDialog in corona facebook api works the same, and both have the same outcome either way. The error is in the form of a toast which disappears given a period of time.I have another code using the facebook api of corona.

local facebook = require “facebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local function listener( event )

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

            facebook.showDialog( “apprequests”, {

                message = “You should download this game!”

            })

        end

    elseif ( “dialog” == event.type ) then

        print( event.response )

    end

end

local function login( event )

    facebook.login( “xxxxxxxxxx”, listener )

end

postText:addEventListener(“tap”, login)

I use a device to check if the code works, but there seems to be an error. I have installed it in three different android devices but the same thing happens if the device already has an installed facebook app. If you have any suggestions on what I should do, I would be happy to do it and very much appreciate it. 

@aukStudios actually, GGFacebook’s makePost and showDialog in corona facebook api works the same, and both have the same outcome either way. The error is in the form of a toast which disappears given a period of time.I have another code using the facebook api of corona.

local facebook = require “facebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local function listener( event )

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

            facebook.showDialog( “apprequests”, {

                message = “You should download this game!”

            })

        end

    elseif ( “dialog” == event.type ) then

        print( event.response )

    end

end

local function login( event )

    facebook.login( “xxxxxxxxxx”, listener )

end

postText:addEventListener(“tap”, login)

I use a device to check if the code works, but there seems to be an error. I have installed it in three different android devices but the same thing happens if the device already has an installed facebook app. If you have any suggestions on what I should do, I would be happy to do it and very much appreciate it. 

One thing I notice in the code you just posted is that you’re missing a title parameter in facebook.showDialog().  I could be wrong, but I think “apprequests” requires a title parameter (in addition to the message parameter that you already have).

I don’t know what you mean by a ‘toast’?  Is that a popup window?

Are you able to see the content of the terminal when you run on the device?  On Android, you have to use adb logcat (see this blog post: http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/).  That could shed a lot of light on the situation.

  • Andrew

@aukStudios Toast is like a small pop-message which disappears in a period of time. I’ll try to read the link you gave, and also try to use logcat because I haven’t tried using it on lua, only in java. Thank you

Hey, @czartezadev, is your app for Android devices, and if so, what Corona daily build version are you using?  Seeing that you are Starter, maybe you don’t have the access to the most recent daily build… hmmm… the conflict between FB native app and FB integrated Corona app have been resolved as of daily build 1179.  

If you don’t have the access to the latest daily build, and you are working on Android version of your app, you’ll have to implement workaround.  In the following thread, Andrew @aukStudios explains in great detail about this issue, and it should help you code the necessary workaround (if you can’t use the daily build 1179 or later):

http://forums.coronalabs.com/topic/37679-facebook-frustrations/

Naomi

Thanks Naomi.  If @czartezadev is using the latest public build, which is build 1137, I think the key login challenge on Android that I described in that post wouldn’t be a problem, since that challenge didn’t start until build 1141.

But, it sounds like @czartezadev is describing a different (potential) issue, one that I haven’t looked it.  @czartezadev is describing a situation where the Facebook app is installed on the device, but it’s not signed in.

@czartezadev, some more information about what you’re seeing would be helpful:

  • After the user signs into the Facebook app, and then it goes back to your app, you said it prompts an error.  What is the error?  Also, what info is passed to your Facebook listener function?

  • Are you calling facebook.login() at some point?

  • What API are you using to post to Facebook?  It sounds like you’re using facebook.showDialog(), probably facebook.showDialog(“feed”).  Is that right?

  • It would help if you posted snippets of your Facebook code so we had a better sense of what you’re doing

  • Andrew

That may be the reason, my daily build is 1135. Thank you, I’ll read the post you linked :slight_smile:

@aukStudios Hi, as for the 1st question, the errors prompts very quickly so I did not have a chance to copy it, but what I have understood is that ‘Login failed, contact app developer to report it to facebook’ something like that and at the end it says facebook error #xxxxx. For the 2nd question, yes, I have been calling facebook.login everytime the user taps the button from my app. For the 3rd question, I have been using the external named GGFacebook which I found on github, it works almost the same facebook API in corona. 

Actually, my problem is that if the installed facebook app is not logged in yet, it goes to the log in page of the installed facebook app then after signing in, it prompts an error. But if the installed facebook app is logged in already, the pop-up works just fine. What happens is that the user have to sign-in twice.

Below is my code:

local toast = require “toast”

local GGFacebook = require “GGFacebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local post = display.newText(“Post message”, 0, 0, native.systemFontBold, 50)

post.x = display.contentWidth/2

post.y = display.contentHeight/2 + 100

post.alpha = 0

local facebook = GGFacebook:new(“xxxxxxxxxxx”) --appID

local function login()

    facebook = GGFacebook:new(“xxxxxxxxxxx”)

    toast.new(“Please wait”, 2000)

    facebook:login()

    facebook:makePost( “https://play.google.com/”, “http://s12.postimg.org/7f47yzq8p/Icon_72.png”, “Rubberducky”, “Android game”, “I got 100 in 120 seconds!”)

end

postText:addEventListener(“tap”, postFunction)

Well, I don’t use GGFacebook, so I may not be able to help you there.

But glancing at your code, a few things strike me:

  • It seems strange that you would call facebook:login() every time the button is pressed, as opposed to just the first time
  • It may not work to call facebook:login() and then, on the next line, call facebook:makePost().  The login process is asynchronous, so you may have to call facebook:makePost() within the callback listener to the login.  (It’s possible that’s not necessary, but my guess is that it is)

Why aren’t you able to copy/paste the exact error you’re seeing?  That would definitely be helpful.  When you say it prompts very quickly, what do you mean exactly?  Does the error show as a popup or something on the device itself?  Or does it show in the terminal output?

  • Andrew

@aukStudios actually, GGFacebook’s makePost and showDialog in corona facebook api works the same, and both have the same outcome either way. The error is in the form of a toast which disappears given a period of time.I have another code using the facebook api of corona.

local facebook = require “facebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local function listener( event )

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

            facebook.showDialog( “apprequests”, {

                message = “You should download this game!”

            })

        end

    elseif ( “dialog” == event.type ) then

        print( event.response )

    end

end

local function login( event )

    facebook.login( “xxxxxxxxxx”, listener )

end

postText:addEventListener(“tap”, login)

I use a device to check if the code works, but there seems to be an error. I have installed it in three different android devices but the same thing happens if the device already has an installed facebook app. If you have any suggestions on what I should do, I would be happy to do it and very much appreciate it. 

@aukStudios actually, GGFacebook’s makePost and showDialog in corona facebook api works the same, and both have the same outcome either way. The error is in the form of a toast which disappears given a period of time.I have another code using the facebook api of corona.

local facebook = require “facebook”

local postText = display.newText(“Post”, 0, 0, native.systemFontBold, 50)

postText.x = display.contentWidth/2

postText.y = display.contentHeight/2

local function listener( event )

    if ( “session” == event.type ) then

        if ( “login” == event.phase ) then

            facebook.showDialog( “apprequests”, {

                message = “You should download this game!”

            })

        end

    elseif ( “dialog” == event.type ) then

        print( event.response )

    end

end

local function login( event )

    facebook.login( “xxxxxxxxxx”, listener )

end

postText:addEventListener(“tap”, login)

I use a device to check if the code works, but there seems to be an error. I have installed it in three different android devices but the same thing happens if the device already has an installed facebook app. If you have any suggestions on what I should do, I would be happy to do it and very much appreciate it. 

One thing I notice in the code you just posted is that you’re missing a title parameter in facebook.showDialog().  I could be wrong, but I think “apprequests” requires a title parameter (in addition to the message parameter that you already have).

I don’t know what you mean by a ‘toast’?  Is that a popup window?

Are you able to see the content of the terminal when you run on the device?  On Android, you have to use adb logcat (see this blog post: http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/).  That could shed a lot of light on the situation.

  • Andrew

@aukStudios Toast is like a small pop-message which disappears in a period of time. I’ll try to read the link you gave, and also try to use logcat because I haven’t tried using it on lua, only in java. Thank you