Facebook Sample Code Under Corona Build 2189a not working on IOS 7.0.4

Can you post your device log here ?

Best Regards,

Team, SP Technolab

www.sptechnolab.com

SP Technolab is asking the right question.  Usually “It works on the sim but not the device” is the result of something the sim cant test like case sensitive file names, or in the case of Facebook… well Facebook.  You have to tether your device to your computer and use Xcode to peek at the device’s console log.  If you do not know how to do this, please read this tutorial:

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

It is impossible to help without knowing what’s going on and that log is the best way to find out.

Hi,

Rob and SP you are right in asking for the log, but the device that we use for testing which is tethered is an IOS 6.0 IPad and IOS 7.0.5 IPhone 5C is a remote device where we send builds via TestFlight so getting a console log would be difficult. 

What we have done here is we have attached our Facebook code on Dropbox and shared the link for the same, so you can go through the same. 

In Corona 1262 this code brings facebook prompt for IOS 6 and Android devices but same this stop working for IOS 7

So if has stop working can u pls tell me how can i get facebook token in 1262 build of Corona for IOS7 devices

this is working fine on Android and IOS6 devices also. 

Link for Dropbox code of Facebook, it has an App Id also that we have created on Facebook for testing. 

https://www.dropbox.com/s/tk5y5pfcujuzzev/facebook-api-part-II.zip

That’s the link…let us know if there is anything else that we need to share.

Sunil

Also we have been noticing that using Build 2189a or Build 2189 if we build for XCode Simulator, it does launch the IOS 7.1. SDK Simulator that is part of XCode 5.1 but the app does not get installed… which is when on the Corona Terminal we get the dvtFoundationBundle : error

Sunil

Hi evolvingstudios

Still you forgot to add facebook plugin in build.settings

 

plugins =
{
[“facebook”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, [“iphone-sim”]=true },
},
},

 

For getting list of Friends you need to call facebook:showDialog( “friends”, listener )    

 

Best Regards,

Team, SP Technolab

www.sptechnolab.com

I am using Corona build : 2014.2189

Best Regards,

Team, SP Technolab

www.sptechnolab.com

At this point, Facebook has made significant changes to their side of things that I don’t know that you can build an app for them with 1262 any more.

We unfortunately can’t build and test your app.  We don’t have the provisioning profiles that match what you’re using, so it would be impossible for us to build with the correct bundle ID that Facebook needs to match.  I would suggest that you join the Corona BETA testers group on Facebook ( There you can solicit people who have volunteered to help test your apps, get their device ID and add it to your testers, generate a build and hook them up through test flight.  They all are Corona developers so they can get console logs for you.  That way you are building against your ID’s

Rob

Hi,

SP / Rob, have attached our code once again which is working perfectly on IOS 6 and Android devices. 

ui = require(“ui”)

local facebook = require “facebook”

require(“Json”)

local widget = require( “widget” )

local myText

local myText1

local appId = “272502539588566”;

local URL;

local userid;

local scrollViewGlobal = nil

local screenGroupp = display.newGroup()

local friendsGroup = display.newGroup()

function onClick( event )

myText.text = event.phase

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

facebook.login( appId, listener, {“publish_stream”} )

end

end

function networkListener( event )

if ( event.isError ) then

myText2.text = “networkListener not called”

else

myText2.text = “networkListener called”

local info = event.response

local response = Json.Decode(event.response)

table.foreach(response,print)

print(#response)

myText.text = response.id

userid = response.id

end

end

function listener( event )

myText.text = event.token

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

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

        myText2.text = event.phase

        myText.text = “Token” …event.token

            

            facebook.request(“me”)  

myButton.isVisible = false

            print(“listeners”)

            

            myText2.text = “listener called”

CorrectScore = 10

_G.CorrectToken = event.token

local URL = "http://tampropack.com/api/createuser.php?token="…_G.CorrectToken…"&score="…CorrectScore 

local requestId = network.request( URL,“POST”, networkListener )

        end

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

        local response = Json.Decode( event.response )

local data = response.data

local function showImage( event )

event.target.alpha = 0

event.target.xScale = 0.25

event.target.yScale = 0.25

            transition.to( event.target, { alpha = 1.0 , xScale = 1, yScale = 1} )

end

for i=1,#data do

display.loadRemoteImage(“http://graph.facebook.com/”… data[i].id …"/picture",

“GET”,

showImage,

“friend”…i…".png", 

system.TemporaryDirectory,

math.random(0,display.contentWidth),

math.random(0,display.contentHeight) )

end

    end

end

myButton = ui.newButton {

        defaultSrc = “fb.png” , defaultX = “300” , defaultY = “50”,

        onEvent = onClick,

        id = “myButton”

}

myButton.x = display.contentWidth / 2

myButton.y = display.contentHeight / 2

myText = display.newText( “Hello World!”, 100, 200, native.systemFont, 16 )

myText2 = display.newText( “Hello World!”, 100, 300, native.systemFont, 16 )

The line where we have  local response = Json.Decode(event.response) in the function networkListener   is returning nil is where we are having issues on IOS7, its working well on IOS 6 and ANdroid devices. 

Hope you are able to replicate the issue with the code and help us find a way out. 

The Corona Build used is 1262.

Sunil

There are multiple things going against you here.

1.  Starting sometime in the mid 2100’s, because Apple started rejecting apps that included the ID for Advertisers (IDFA), we had to move the Facebook API to a plugin.  That way, apps not using facebook would not get rejected by Apple.  Apps using Facebook can click the right series of check boxes and get approved.   To use any of the later builds including 2189a, you must include the necessary code in your build.settings file.   Your build.settings file in your zip file is missing that code.  SP Technolab provided the required code for you to use above twice.  You will simply not work with 2189 or later if you do not do this.  This is for iOS only.  On Android, it’s not a plugin.  See: http://docs.coronalabs.com/api/library/facebook/index.html

2.  Since Corona SDK is now using Facebook as a plugin (and for Android running later builds), we are now using the SDK v2 protocol for Facebook.  1262 is built against the older protocol.  You need to do a 2-step login.  The first time requests basic permissions and sets up your listener.  The second time, you can request enhanced permissions, though it seems that Facebook is now going through some form of approval process for apps that want extended permissions.

3.  If you get a black screen on the device, we need to know what’s in the device’s console log.  I provided a tutorial above that shows you how to get that information.  I don’t see where you provided it.  It will likely point to problems.  You can also put in print statements to see what the network listener is returning and maybe get some clues there.  But it starts with reading that console log.

So if you want to use a more modern build (which you very likely will have to do to pass both Apple and Facebook requirements) you have to include the plugin code and abide by the latest Facebook way of doing things.

Rob

Hi !

i’m getting this error with my app 
Runtime error?:0: attempt to call field ‘login’ (a nil value)stack traceback:

and I try the file from the Link for Dropbox code of Facebook and the same… Any Help!! 

That sounds like you are not including the required plugin code in your build.settings or there is an error in your build.settings.   There are probably more messages in your device’s console log that could pin point this. 

If you don’t know how to read your console log, consult this post:   http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Please post the relevant part of your console log here, along with your build.settings, your code you are using to initialize and login to facebook as well.

Also what version of Corona SDK are you using?

What platform are you trying to build for and build on?

Hi Rob

Corona Version 2189

IOS app

 

Using additional build settings from: /Users/plmarcot/Library/Application Support/Outlaw/Sandbox/96/build.settings

 

mv: rename /Users/plmarcot/Desktop/BuildCorona/facebook.app/icon.png to /Users/plmarcot/Desktop/BuildCorona/facebook.app/Icon.png: No such file or directory

 

App Spec: <DTiPhoneSimulatorApplicationSpecifier 0x7f8710d369b0> specified by path /Users/plmarcot/Desktop/BuildCorona/facebook.app

SDK Root: <DTiPhoneSimulatorSystemRoot 0x7f8710d33260> path=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk version=7.1 name=Simulator - iOS 7.1

Creating named pipe at `/var/folders/qv/r1rb5mms5b58jy8bbz5sjg5m0000gn/T//ios-sim-stderr-pipe-1401655179’

Creating named pipe at `/var/folders/qv/r1rb5mms5b58jy8bbz5sjg5m0000gn/T//ios-sim-stdout-pipe-1401655179’

using device family iphone

using retina

SimulateDevice: iPhone Retina (4-inch)

Calling: setSimulatedDeviceInfoName: iPhone Retina (4-inch) (iPhone Retina (4-inch 64-bit))

 

Session started

 

2014-06-01 16:40:09.037 facebook[9160:70b] Platform: iPhone Simulator / x86_64 / 7.1 / Apple Software Renderer / OpenGL ES 2.0 APPLE-9.4.3

2014-06-01 16:40:09.082 facebook[9160:70b] fb1389327051306781

2014-06-01 16:40:09.083 facebook[9160:70b] Runtime error

/Users/plmarcot/Library/Application Support/Outlaw/Sandbox/96/main.lua:19: attempt to call field ‘login’ (a nil value)

stack traceback:

/Users/plmarcot/Library/Application Support/Outlaw/Sandbox/96/main.lua:19: in main chunk

 

2014-06-01 16:40:09.372 facebook[9160:70b] AppDelegate.mm: didFailToRegisterForRemoteNotificationsWithError: remote notifications are not supported in the simulator

What is line 19 of your main.lua?

Are you doing a:   local facebook = require(“facebook”)? 

What does your build.settings look like?

settings = { orientation = { default = "landscapeRight", supported = { "landscapeLeft", "landscapeRight" }, }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.ads.iads"] = { -- required publisherId = "com.coronalabs", ["facebook"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, ["iphone-sim"]=true }, }, iphone = { plist= { UIApplicationExitsOnSuspend = false, FacebookAppID = "1510121132542868", CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1510121132542868", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png" } } } } }, }, }, }, }

19- facebook.login( FBAppID, listener, { “publish_actions” } )

It looks to me like you have an error in your build.settings file. 

&nbsp;&nbsp;&nbsp;&nbsp; plugins = &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- key is the name passed to Lua's 'require()' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["CoronaProvider.ads.iads"] = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- required &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publisherId = "com.coronalabs", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["facebook"] = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publisherId = "com.coronalabs", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; supportedPlatforms = { iphone=true, ["iphone-sim"]=true }, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp;&nbsp; },

You’re braces are not ending correctly.  It really helps to indent your code for each level so you can quickly line up the braces and spot errors.  I had to close two sets of braces to balance things out.  A quick look above makes me thing you have too many braces at the bottom.  Spend some time getting your indents correct and make sure everything is at the right level.  The plugin block is a peer to iphone, orientation, etc.

Thanks Rob!! The problem was the braces.

Hi,

Rob we have enclosed our console log let us know if this can provide some insight into the black screen issue for Facebook Sample code for Corona Build 2189.

04/06/14 6:04:04.292 pm com.apple.IconServicesAgent[195]: main Failed to composit image for binding VariantBinding [0x3cd] flags: 0x8 binding: FileInfoBinding [0x457] - extension: pptx, UTI: org.openxmlformats.presentationml.presentation, fileType: ???.

04/06/14 6:04:04.293 pm quicklookd[4316]: Warning: Cache image returned by the server has size range covering all valid image sizes. Binding: VariantBinding [0x203] flags: 0x8 binding: FileInfoBinding [0x103] - extension: pptx, UTI: org.openxmlformats.presentationml.presentation, fileType: ??? request size:16 scale: 1

04/06/14 6:04:04.656 pm Console[4318]: setPresentationOptions called with NSApplicationPresentationFullScreen when there is no visible fullscreen window; this call will be ignored.

04/06/14 6:04:19.552 pm Corona Simulator[4304]: validationTool: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation

04/06/14 6:04:46.018 pm iTunes[4526]: Entered:_AMMuxedVersion2DeviceConnected, mux-device:2

04/06/14 6:04:46.022 pm iTunes[4526]: tid:1203 - unable to query device capabilities

04/06/14 6:04:47.615 pm com.apple.SecurityServer[14]: Session 100022 created

04/06/14 6:04:50.258 pm AppleMobileBackup[4533]: WARNING: Backing up ddf08ebde12c374fcf67f6146d6801f4b4d289f2

04/06/14 6:04:53.513 pm MDCrashReportTool[4535]: 4535:3674112|CrashReportCopierAFC.m:-[CrashReportCopierAFC copyAndProcessRemotePath:usingConnection:]| ERROR: Could not remove remote path at ./DiagnosticLogs/security.log.20140604T114037Z

04/06/14 6:04:56.736 pm com.apple.usbmuxd[26]: MuxTCPInputSCE received RST for 0x2-ddf08ebde12c374fcf67f6146d6801f4b4d289f2@0xfd140000:52122->0x100518e20-MDCrashReportTool/NULL:19462: sendMuxSegment connection was closed

04/06/14 6:04:56.876 pm MDCrashReportTool[4536]: 4536:4722688|CrashReportCopierAFC.m:-[CrashReportCopierAFC copyAndProcessRemotePath:usingConnection:]| ERROR: Could not remove remote path at ./DiagnosticLogs/security.log.20140604T114037Z

04/06/14 6:04:57.344 pm com.apple.usbmuxd[26]: MuxTCPInputSCE received RST for 0x2-ddf08ebde12c374fcf67f6146d6801f4b4d289f2@0xfd140000:52167->0x1002099e0-iTunes/com.apple.iTunes:26374: sendMuxSegment connection was closed

04/06/14 6:04:58.742 pm mds[39]: (Normal) ImportServer: Ignoring blacklisted Spotlight importer plugin:/Developer/old/Applications/Xcode.app/Contents/Library/Spotlight/SourceCode.mdimporter uuid:548A3091-3C5D-498A-A329-B532A6C896BB version:1801

04/06/14 6:05:09.107 pm Finder[143]: FIXME: IOUnserialize has detected a string that is not valid UTF-8, “*”.

04/06/14 6:05:09.130 pm Finder[143]: FIXME: IOUnserialize has detected a string that is not valid UTF-8, “*”.

04/06/14 6:05:18.569 pm Finder[143]: FIXME: IOUnserialize has detected a string that is not valid UTF-8, “*”.

04/06/14 6:05:38.136 pm com.apple.usbmuxd[26]: MuxTCPInputSCE received RST for 0x2-ddf08ebde12c374fcf67f6146d6801f4b4d289f2@0xfd140000:52736->0x10040e210-MDCrashReportTool/NULL:51463: sendMuxSegment connection was closed

04/06/14 6:05:38.242 pm MDCrashReportTool[4541]: 4541:4722688|CrashReportCopierAFC.m:-[CrashReportCopierAFC copyAndProcessRemotePath:usingConnection:]| ERROR: Could not remove remote path at ./DiagnosticLogs/security.log.20140604T114037Z

04/06/14 6:05:39.642 pm iTunes[4526]: AMDeviceSecureTransferPath (thread 0x10a548000): disableDelta: FALSE

04/06/14 6:06:21.534 pm mds[39]: (Normal) ImportServer: Ignoring blacklisted Spotlight importer plugin:/Developer/old/Applications/Xcode.app/Contents/Library/Spotlight/SourceCode.mdimporter uuid:548A3091-3C5D-498A-A329-B532A6C896BB version:1801

04/06/14 6:06:30.116 pm iTunes[4526]: BUG in libdispatch client: kevent[EVFILT_WRITE] delete: “No such file or directory” - 0x2

04/06/14 6:07:53.000 pm kernel[0]: en1: BSSID changed to ec:43:f6:76:54:58

04/06/14 6:07:54.000 pm kernel[0]: AirPort: RSN handshake complete on en1

Sorry Rob wrong console log 

Pls use the one attached below

a notification

Jun  4 18:43:08 lenovos-iPad mobile_assertion_agent[133] <Notice>: service_one_connection: Connection closed for client iTunes.

Jun  4 18:43:35 lenovos-iPad kernel[0] <Debug>: launchd[926] Container: /private/var/mobile/Applications/3F7664C0-75F7-4C0A-9597-ED6021FB85C1 (sandbox)

Jun  4 18:43:35 lenovos-iPad backboardd[28] <Error>: HID: The ‘Passive’ connection ‘Facebook-Test’ access to protected services is denied.

Jun  4 18:43:35 lenovos-iPad networkd[79] <Warning>: Analytics Engine: double ON for app: com.deevolutionstudios.gravefall

Jun  4 18:43:35 lenovos-iPad Facebook-Test[926] <Warning>: Platform: iPad / iPad3,6 / 7.1.1 / PowerVR SGX 554 / OpenGL ES 2.0 IMGSGX554-97.7

Jun  4 18:43:35 lenovos-iPad Facebook-Test[926] <Warning>: Runtime error

module ‘facebook’ not found:resource (facebook.lu) does not exist in archive

no field package.preload[‘facebook’]

no file ‘/var/mobile/Applications/3F7664C0-75F7-4C0A-9597-ED6021FB85C1/Facebook-Test.app/facebook.lua’

no file ‘/var/mobile/Applications/3F7664C0-75F7-4C0A-9597-ED6021FB85C1/Facebook-Test.app/facebook.lua’

no file ‘./facebook.so’

no file '/var/mobile/Applications/3F7664C0-75F7-4C0A-9597-ED6021FB85C1/Facebook-Test.app/facebook.so’facebook

stack traceback:

[C]: in function ‘require’

?: in function ‘require’

?: in main chunk

What is your build.settings like @evolvingstudios?

Hi Rob below is our build.settings

settings =

{

orientation =

{

default = “portrait”,

supported = { “portrait” }

},

android =

{

usesPermissions =

{

“android.permission.INTERNET”,

},

},

 

plugins =

{

– key is the name passed to Lua’s ‘require()’ This section is only required for builds > 2014.2165

[“facebook”] =

{

– required

publisherId = “com.coronalabs”,

supportedPlatforms = { iphone = true, [“iphone-sim”] = true },

},

},

 

iphone =

{

plist =

{

CFBundleIconFile = “Icon.png”,

CFBundleIconFiles =

{

                “Icon.png”, 

                “Icon@2x.png”, 

                “Icon-60.png”,

                “Icon-60@2x.png”,

                “Icon-72.png”, 

                “Icon-72@2x.png”,

                “Icon-76.png”,

                “Icon-76@2x.png”, 

                “Icon-Small.png”, 

                “Icon-Small@2x.png”,

                “Icon-Small-40.png”,

                “Icon-Small-40@2x.png”,

                “Icon-Small-50.png”, 

                “Icon-Small-50@2x.png”, 

},

UIApplicationExitsOnSuspend = false, – must be false for single sign-on to work

FacebookAppID = “XXXXXXXXXXXXXXXXX”, – replace XXXXXXXXX with your facebook appId

 

CFBundleURLTypes =

{

{

CFBundleURLSchemes =

{

“fbXXXXXXXXXXXXXXX”, – replace XXXXXXXXX with your facebook appId

 

}

}

}

}

}

}