Having problems getting the Facebook v4 iOS plugin to login, possibly due to ATS

As it turns out, I’d already tested with a non-default permission “user_games_activity” (at least I don’t think it’s accepted by default), and that hadn’t worked. Just tried with “email” and the same thing happened.  

I’ve also just tested with App Transport Security Settings->Allow Arbitrary Loads set to true, just in case there was a request being blocked by ATS. Same thing, it all appears like it’s working but then the listener only receives a “loginCancelled” phase.

If it’s any help, I’m using Xcode 7.2 and Corona Enterprise build 2015.2743 - presumably there is nothing about those builds in particular that should be causing this issue? I could test with a newer Enterprise build, but I’m always reluctant in case something else has been changed in the meantime that I rely on (e.g. when storyboard was deprecated - an easy fix but easy to overlook until you need to update it).

Alan, not sure if you ever got this going or not but I recently ran into the same issue and it required two changes to work.

  1. Add the NSAllowsArbitraryLoads = true to your build.settings file (which you did)

  2. Comment out all of the NSExceptionDomains (see snippet below)

I had to do both of those to make ATS happy. I know this is not the safest route but it was the only way I could get it to work.

HTH!

Scott

           -- Whitelist Facebook Servers for Network Requests             NSAppTransportSecurity =              { NSAllowsArbitraryLoads = true --                NSExceptionDomains =  --                { --                    ["fbcdn.net"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false, --                    }, --                    ["facebook.com"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false,                    }, --                    ["akamaihd.net"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false,                    }, --                },             },

Thanks Scott, I still didn’t have it working and moved onto other things. I’ll try this when I next get a chance and hopefully it will work for me too!

I put this on the back burner while I looked at some Android stuff that I needed to do, and have come back to it today.  

I’ve just updated Corona to the latest daily build 2016.2830 and tried again (I also grabbed the FB-v4 lib again in case it had been updated). I’m still getting the exact same error. As I said in my original posts, the URL used by FB to return to my app makes it seem as though everything is being sent back correctly, but then it always triggers the “cancelled” phase. I’ve also tried using a brand new Facebook account, just to see if that made any difference (it didn’t).

Has nobody else ran into this problem? I’m pulling my hair out trying to work out why this is happening.

I have the same issue happening to me - but only to some users (not consistently) and on Android as well as iOS. 

The users try to log-in with facebook. They already accepted the permissions before, so the login does not ask for them. Immediately they get the fbconnect event:

type: session name: fbconnect phase: loginCancelled isError: false response: 

Engineering is aware of the loginCancelled issue. They are investigating.

i am facing this problem also, since the google give alert for opensll, and i really need to use new corona sdk to able to use the new openssl plugin, but to be able to use new corona sdk with its new opensll plugin i must change the facebook plugin to v4,

is there any way to use the old facebook plugin, so i can use new corona sdk with new openssl plugin without changing the facebook plugin

thanks

You can continue to use the older facebook plugin.

Rob

i still can nott use the old facebook plugin with corona sdk build number 2910,

here is the error

Module ‘facebook’ not found:
    no field package.preload[‘facebook’]
    no file ‘/Users/chandra/Library/Application Support/Corona/Simulator/Plugins/facebook.lua’
    no file ‘/Users/chandra/Documents/svnx/_12.BaliFied/code/release/1.5/code/Corona/facebook.lua’
    no file ‘/Applications/CoronaSDK-2910/Corona Simulator.app/Contents/Resources/facebook.lua’
    no file ‘/Users/chandra/Library/Application Support/Corona/Simulator/Plugins/facebook.dylib’
    no file ‘./facebook.dylib’
    no file ‘/Applications/CoronaSDK-2910/Corona Simulator.app/Contents/Resources/facebook.dylib’

File: module ‘facebook’ not found
 

also when i go to https://store.coronalabs.com/plugins?field_primary_category_tid=9&sort_by=title&sort_order=ASC&items_per_page=12

and look up for facebook plugin and i saw the button is “pre-activated” and i can’t activate it

thank you

Can you post your build.settings?

– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {
    
    excludeFiles =
       {
        --all = { “*secret.txt”, “artwork/*” },
          iphone = { “Icon-*dpi.png” },
          android = { “Icon.png”, “512x512.png”, “1024x1024.png” }
       },
    orientation =
    {
        default = “portrait”,  – Initial launch orientation
        content = “portrait”,  – Locked orientation of the Corona stage, independent of Native UI elements (iOS only)
        supported = {“portrait” },  – Table of allowed options for auto-orientation
    },
        
    plugins =
    {
        [“CoronaProvider.native.popup.social”] =
        {
            publisherId = “com.coronalabs”
        },
        [“plugin.photon”] =
        {           
            publisherId = “com.exitgames”,
        },
        [“plugin.openssl”] =
        {
           publisherId = “com.coronalabs”,
–           supportedPlatforms = { android = true, iphone = true, [“mac-sim”] = true, [“win32-sim”] = true },
        },
–         [“plugin.notifications”] =
–         {
–            publisherId = “com.coronalabs”
–         },
        [“facebook”] =
        {
            publisherId = “com.coronalabs”,
            supportedPlatforms = { iphone=true, android=true },
        },
        [“CoronaProvider.gameNetwork.apple”] =
        {
            publisherId = “com.coronalabs”,
            supportedPlatforms = { iphone=true }
        },
        [“CoronaProvider.gameNetwork.google”] =
        {
            publisherId = “com.coronalabs”,
            supportedPlatforms = { android=true },
        },
        [“plugin.google.iap.v3”] =
        {
            publisherId = “com.coronalabs”,
            supportedPlatforms = { android=true }
        },       
        --[“plugin.zip”] =
        --{
        –    publisherId = “com.coronalabs”
        --},
        [“plugin.gameanalytics”] =
        {
            publisherId = “com.gameanalytics”,
        },
        [“plugin.advertisingId”] =
        {
            publisherId = “com.coronalabs”
        },
        [“plugin.OneSignal”] =
        {
            publisherId = “com.onesignal”,
        },
        [“plugin.google.play.services”] =
        {
            publisherId = “com.coronalabs”,
            supportedPlatforms = { android=true, [“android-kindle”]=true },
        },
        [“plugin.chartboost”] =
        {
            publisherId = “com.swipeware”
        },
    },
    
    iphone = {
        plist = {
            --UILaunchStoryboardName = “LaunchScreen”,            
            CFBundleIconFile = “Icon.png”,
            CFBundleIconFiles = {
                “Icon.png”,
                “Icon@2x.png”,
                “Icon-60.png”,
                “Icon-60@2x.png”,
                “Icon-60@3x.png”,
                “Icon-72.png”,
                “Icon-72@2x.png”,
                “Icon-76.png”,
                “Icon-76@2x.png”,
                “Icon-167.png”,
                “Icon-Small-40.png”,
                “Icon-Small-40@2x.png”,
                “Icon-Small-40@3x.png”,
                “Icon-Small-50.png”,
                “Icon-Small-50@2x.png”,
                “Icon-Small.png”,
                “Icon-Small@2x.png”,
                “Icon-Small@3x.png”
            },            
            – CoronaWindowMovesWhenKeyboardAppears = true,
            UIBackgroundModes = {“remote-notification”},
            UIApplicationExitsOnSuspend = false,
            UIStatusBarHidden = true,
            UIPrerenderedIcon = true,
            
            UIAppFonts =
            {
                “calibri.ttf”,
                “calibrib.ttf”,
                “calibrii.ttf”,
                “calibriz.ttf”
            },

            FacebookAppID = “XXXXXXXXXX”,
            CFBundleURLTypes =
            {
                 {
                    CFBundleURLSchemes =
                    {                     
                      “fbXXXXXXXXXX”,
                    }
                 }
            },
            --CFBundleIdentifier = “com.dragongamestudio.dragonslots”,
            CFBundleIdentifier = “com.XXXXXXXXXX.XXXXXXXXXX”,

            [“URL types”] =
            {
                item =
                {
                    [“URL Schemes”] = { [“Item 0”] = “fbXXXXXXXXXX” },
                },
            },
            
            plist =
            {
                CoronaDelegates = { “CoronaNotificationsDelegate”}
            },
            – Whitelist Facebook Servers for Network Requests
            NSAppTransportSecurity =
            {
                NSExceptionDomains =
                {
                    [“fbcdn.net”] =
                    {
                        NSIncludesSubdomains = true,
                        NSExceptionRequiresForwardSecrecy = false,
                    },
                    [“facebook.com”] =
                    {
                        NSIncludesSubdomains = true,
                        NSExceptionRequiresForwardSecrecy = false,
                    },                    
                    [“akamaihd.net”] =
                    {
                        NSIncludesSubdomains = true,
                        NSExceptionRequiresForwardSecrecy = false,
                    },               
                    [“api.gameanalytics.com”]={
                        NSIncludesSubdomains = true,
                        NSThirdPartyExceptionAllowsInsecureHTTPLoads = true
                    },
                },
            },

            – Whitelist Facebook Apps
            LSApplicationQueriesSchemes =
            {
                “fb”,
                “fbapi20130214”,
                “fbapi20130410”,
                “fbapi20140410”,
                “fbapi20140116”,
                “fbapi20150313”,
                “fbapi20150629”,
                “fbauth”,
                “fbauth2”,
                “fb-messenger-api20140430”,
            },
        },
    },
    
    android =
    {
        – coronaWindowMovesWhenKeyboardAppears = true,
        
        googlePlayGamesAppId = “XXXXXXXXXX”,
        facebookAppId = “XXXXXXXXXX”,  – Replace XXXXXXXXXX with your Facebook App ID
        CFBundleDisplayName = “XXXXXXXXXX”,
        CFBundleName = “com.XXXXXXXXXX.XXXXXXXXXX”,
        UIApplicationExitsOnSuspend = false,
        UIPrerenderedIcon = true,
        UIStatusBarHidden = true,
        permissions =
        {
            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },
        },
        --usesExpansionFile = true,
        usesPermissions =
        {
            “com.android.vending.BILLING”,
            “android.permission.INTERNET”,
            “android.permission.READ_PHONE_STATE”,
            “android.permission.VIBRATE”,
            “android.permission.ACCESS_NETWORK_STATE”,
            “android.permission.GET_ACCOUNTS”,
            “android.permission.RECEIVE_BOOT_COMPLETED”,
            “com.google.android.c2dm.permission.RECEIVE”,
            “.permission.C2D_MESSAGE”,
            “com.android.vending.CHECK_LICENSE”,
            “android.permission.WRITE_EXTERNAL_STORAGE”
        },
        androidPermissions =
        {
            “com.android.vending.BILLING”,
            “android.permission.INTERNET”,
            “android.permission.READ_PHONE_STATE”,
            “android.permission.VIBRATE”,
            “android.permission.ACCESS_NETWORK_STATE”,
            “android.permission.GET_ACCOUNTS”,
            “android.permission.RECEIVE_BOOT_COMPLETED”,
            “com.google.android.c2dm.permission.RECEIVE”,
            “.permission.C2D_MESSAGE”,
            “com.android.vending.CHECK_LICENSE”,
            “android.permission.WRITE_EXTERNAL_STORAGE”
        },
    },
}
 

Can you humor me and comment out the supportedPlatforms line for the facebook plugin?

i have try that, like this you mean

        [“facebook”] =
        {
            publisherId = “com.coronalabs”,
–            supportedPlatforms = { iphone=true, android=true },
        },

but it still give me error message like above

Module ‘facebook’ not found:
    no field package.preload[‘facebook’]
    no file ‘/Users/chandra/Library/Application Support/Corona/Simulator/Plugins/facebook.lua’
    no file ‘/Users/chandra/Documents/svnx/_12myproject/code/release/1.5/code/Corona/facebook.lua’
    no file ‘/Applications/CoronaSDK-2910/Corona Simulator.app/Contents/Resources/facebook.lua’
    no file ‘/Users/chandra/Library/Application Support/Corona/Simulator/Plugins/facebook.dylib’
    no file ‘./facebook.dylib’
    no file ‘/Applications/CoronaSDK-2910/Corona Simulator.app/Contents/Resources/facebook.dylib’

File: module ‘facebook’ not found

Hi DragonGameStudio,

From what you’ve posted, it looks like you’re only having this issue with the Corona Simulator. Have you tried building for device?

From the Facebook legacy plugin documentation:

Starting with daily build 2015.2747, we’ve removed the Corona Simulator plugin stub for this plugin from Corona SDK. This is to encourage upgrading to the Facebook-v4 plugin.

If you do a device build of your project, it should still build successfully with the latest daily build.

If you need this Facebook plugin stub for testing in the Corona Simulator, please revert to any daily build prior to 2015.2747.

I’ve seen this right now as I’ve faced -probably- a similar (or same) issue.

I’m having problems when I try to post a link with Facebook v4 integration.

It opens up the Facebook interface for authorization and after that when I try to post the link, it says “the link may be harmful. please enter captcha code” (something like that).

The user enters the code successfully and the share interface with everything I want. The link, image, score of player.

When I press “Share”, Facebook redirects me to the Login page saying “you have to log in first” even though I’m logged in and gave the appropriate permissions to the app.

I don’t think it matters but I’m using daily build 2016.2870.

Alan, not sure if you ever got this going or not but I recently ran into the same issue and it required two changes to work.

  1. Add the NSAllowsArbitraryLoads = true to your build.settings file (which you did)

  2. Comment out all of the NSExceptionDomains (see snippet below)

I had to do both of those to make ATS happy. I know this is not the safest route but it was the only way I could get it to work.

HTH!

Scott

           -- Whitelist Facebook Servers for Network Requests             NSAppTransportSecurity =              { NSAllowsArbitraryLoads = true --                NSExceptionDomains =  --                { --                    ["fbcdn.net"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false, --                    }, --                    ["facebook.com"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false,                    }, --                    ["akamaihd.net"] =  --                    { --                        NSIncludesSubdomains = true, --                        NSExceptionRequiresForwardSecrecy = false, --                        NSExceptionAllowsInsecureHTTPLoads = false,                    }, --                },             },

Thanks Scott, I still didn’t have it working and moved onto other things. I’ll try this when I next get a chance and hopefully it will work for me too!

I have the same issue happening to me - but only to some users (not consistently) and on Android as well as iOS. 

The users try to log-in with facebook. They already accepted the permissions before, so the login does not ask for them. Immediately they get the fbconnect event:

type: session name: fbconnect phase: loginCancelled isError: false response: 

Engineering is aware of the loginCancelled issue. They are investigating.

i am facing this problem also, since the google give alert for opensll, and i really need to use new corona sdk to able to use the new openssl plugin, but to be able to use new corona sdk with its new opensll plugin i must change the facebook plugin to v4,

is there any way to use the old facebook plugin, so i can use new corona sdk with new openssl plugin without changing the facebook plugin

thanks