In the screen shot above, you show a folder called Documents. Is this your Corona SDK simulator sandbox? It’s not the same folder as the Xcode simulator sandbox.
I accessed my /Users/danny_roerring/Library/Application Support/iPhone Simulator/7.1/Applications/2F58DD96-66B8-4D72-81B9-9354B15C80CB/BeetleJuice.app/BeetleJuice
which I suspect is my Xcode Simulator Sandbox can can see
Good catch the missing ueue.png into log.
It also is missing in the code because I changed some names before posting it, in order to make it more readable, that’s why they don’t match.
Anyway, the log says the image is missing and this is a fact. Now I should understand why!
thanks,
g
I rewrote everything and I add the functionality of screenshot saving and – EVERYTHING WORKS!
I don’t really know what did not work before and I am investigating about it.
Thanks to everybody!
g
@Savorok, what messages are you getting in your console log? For the Xcode simulator you have to run the “Console” app to see it.
Hopefully I have done this right but here is the output attached (XCode.png)
Quick Note:
- Dose the application on Facebook need to be out of Developer mode or could that be causing it?
I checked and created a Test app within the Facebook portal and when using the app ID I get the following also attached (Example.png)
It looks to me like there is an issue with GameThrive based on what I could see. Normally people will use their mouse and highlight the text in Xcode’s Organizer window and then do a Copy (CMD-C) and then come here and paste it in (CMD-V). It’s really hard to make out what’s going on when you just screen shot the screen.
Perhaps you should consider asking this in the GameThrive sub-forum since the error seems related to them.
Rob
My apologies Rob I thought a screenshot might have been easier. Ignore the GameThrive it’s fully working so unsure as to why its generating this error but that’s another problem.
The image appears to be appearing in my “documents” directory. Renamed it to start with a lower case “f” to check this and worked fine so this cannot be the problem. Maybe you might be able to see something on the log that I cannot see.
Jun 8 23:19:38 Dannys-MacBook-Pro.local SimulatorBridge[12203] \<Warning\>: Application launched after 0.00 seconds. Jun 8 23:19:39 Dannys-MacBook-Pro.local backboardd[12191] \<Error\>: HID: The 'Passive' connection 'BeetleJuice' access to protected services is denied. Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: Platform: iPhone Simulator / x86\_64 / 7.1 / Apple Software Renderer / OpenGL ES 2.0 APPLE-9.4.3 Jun 8 23:19:39 Dannys-MacBook-Pro.local SpringBoard[12200] \<Warning\>: Remote notifications are not supported in the simulator Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: Facebook Credits: false Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: Twitter Credits: true Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: AppDelegate.mm: didFailToRegisterForRemoteNotificationsWithError: remote notifications are not supported in the simulator Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: Runtime error /Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin\_GameThrivePushNotifications.lua:292: attempt to concatenate field 'token' (a nil value) stack traceback: /Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin\_GameThrivePushNotifications.lua:292: in function \</Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin\_GameThrivePushNotifications.lua:270\> ?: in function \<?:218\> Jun 8 23:19:50 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: Registration Successful Jun 8 23:20:04 Dannys-MacBook-Pro.local BeetleJuice[14434] \<Warning\>: WARNING: gameNetwork.init() was already called for gamecenter.
Edit: The above is with changing my file copy code to the following aswell, but like I said I can confirm the image is copied correctly.
[lua] --Read the exiciting FaceBookIcon from the resource directory (image is in same drector as my main.lua and other files)
–Read image and convert image to a binary form
local pathRead = system.pathForFile( “FaceBookIcon.jpg”,system.ResourceDirectory )
local file = io.open( pathRead, “rb” )
local imageData = file:read( “*a” )
io.close( file )
–Setup write directory to my documesnts directoy that my settings have been saved to
–Write the binary file and close and set FileStream back to nil
local pathWrite = system.pathForFile( “faceBookIcon.jpg”, system.DocumentsDirectory )
local file = io.open( pathWrite, “wb” )
file:write( imageData )
io.close( file )
file = nil[/lua]
EDIT: This works fine “facebook.request( “me/feed”, “POST”, { message=“Hello Facebook” } )” so it appears its defiantly picture related.
You have an error coming from GameThrive:
Jun 8 23:19:39 Dannys-MacBook-Pro.local BeetleJuice[14434] <Warning>: Runtime error
/Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin_GameThrivePushNotifications.lua:292: attempt to concatenate field ‘token’ (a nil value)
stack traceback:
/Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin_GameThrivePushNotifications.lua:292: in function </Users/hiptic/Documents/GameThrive/SDK/Corona/SDK/shared/plugin_GameThrivePushNotifications.lua:270>
?: in function <?:218>
The only difference I see in your code and code I’ve tested multiple times that works is you’re providing a link and that may be causing your problem. Link is not a valid option for “me/photos”. See:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/photos
GameThrive dev here – That error normally happens because your iOS provisioning profile does not have push permissions on it, but in this case it’s probably happening because push notifications aren’t available on the simulator.
For either case, we’ll be releasing an update soon to have a better message displayed when this error is encountered.
The error happens in a callback, so it shouldn’t have any effect on other parts of your app.
It’s possible this error is because you are using an invalid permission name. Here’s what Facebook says about “publish_stream”:
Facebook used to have a permission called publish_stream. publish_actions replaces it in all cases. This permission also replaces photo_upload.
(https://developers.facebook.com/docs/facebook-login/permissions/v2.0)
So basically, you should replace publish_stream with publish_actions. Also, this permission now requires approval by Facebook to use. But hopefully it should still work in development mode without any special approval.
Updated my previous post with a bunch of new info. Replying again to notify people subscribed to this thread.
Hi,
any solution to this issue? I still get an error #324 if I attempt to upload a picture (jpg) from system.DocumentsDirectory
What’s wrong?
Thanks
g
Can you post some code?
Thanks
Rob
Hi Rob,
here my code
local facebook = require( "facebook" ) local fbAppID = "1234567890" -- this is a fake AppID local function onLoginSuccess() local attachment = { message = "Test Message", source = { baseDir=system.DocumentsDirectory, filename="testPicture.jpg", type="image" } } facebook.request( "me/photos", "POST", attachment ) end local json = require( "json" ) local function fbListener( event ) if event.isError then native.showAlert( "ERROR", event.response, { "OK" } ) else if event.type == "session" and event.phase == "login" then -- login was a success; call function onLoginSuccess() elseif event.type == "request" then -- this block is executed upon successful facebook.request() call native.showAlert( "Success", "The photo has been uploaded.", { "OK" } ) end end end facebook.login( fbAppID, fbListener, { "publish\_stream" } )
AppID in the code is not the real one. This code produces a #324 error whereas if I use baseDir=system.ResourceDirectory instead of baseDir=system.DocumentsDirectory everything works fine. Obviously, the picture is inside both directories (in the Build one for ResourceDirectory case and in Sandbox/Documents for DocumentsDirectory.
I also attempted to change picture (different sizes but always JPG).
What’s wrong in my code?
Thanks for your support,
g
When I tried this, if I used system.ResourceDirectory, I got the error. However if I used system.DocumentsDirectory it worked as it should. How are you getting the image into your Sandbox Documents? If you are doing it through the Simulator, that’s only putting it in sandbox for the simulator. I had to write a little code to download an image to put in my system.DocumentsDirectory. I guess I could have written a function that would have copied the image from system.ResourcesDirectory to system.DocumentsDirectory.
Also, technically speaking the type should be “image/jpeg” or “image/png” depending on the file type needed, though Facebook didn’t seem to care.
Because on Android, the system.ResourcesDirectory technically doesn’t exist, you may have trouble accessing files in it. You need to do a system.pathForFile() to cause us to extract it from the zip file. We do this automatically for images that are accessed via display.* functions.
Rob
Hey Rob,
I appear to be having a similar issue to the above, rather then opening another Thread I thought I would add to this one for collaboration.
I have done what you said above with the code below and can see the image is saving successfully to my ResourcesDirectory folder along side my settings but when I access Facebook I get
ERROR
The operation couldn’t be completed (com.facebook error 123.)
CODE:
[lua]
local function onFaceBookShareRelease( … )
–Read the exiciting FaceBookIcon from the resource directory (image is in same drector as my main.lua and other files)
–Read image and convert image to a binary form
local pathRead = system.pathForFile( “FaceBookIcon.jpg”,system.ResourceDirectory )
local file = io.open( pathRead, “rb” )
local imageData = file:read( “*a” )
io.close( file )
–Setup write directory to my documesnts directoy that my settings have been saved to
–Write the binary file and close and set FileStream back to nil
local pathWrite = system.pathForFile( “FaceBookIcon.jpg”, system.DocumentsDirectory )
local file = io.open( pathWrite, “wb” )
file:write( imageData )
io.close( file )
file = nil
–Setup my Facebook ID
local fbAppID = “1405306663086221” --fake
–iF login = success then create the attachment and send it to facebook
local function onLoginSuccess()
– Upload ‘FaceBookIcon.jpg’ to current user’s account
local attachment = {
message = "I just started playing Beetle Juice, come join me in squashing some bugs! ",
source = { baseDir=system.DocumentsDirectory, filename=“FaceBookIcon.jpg”, type=“image” },
link = “http:roedangames.net”
}
facebook.request( “me/photos”, “POST”, attachment )
end
– facebook listener
local function fbListener( event )
if event.isError then
native.showAlert( “ERROR”, event.response, { “OK” } )
else
if event.type == “session” and event.phase == “login” then
– login was a success; call function
onLoginSuccess()
elseif event.type == “request” then
– this block is executed upon successful facebook.request() call
native.showAlert( “Success”, “The photo has been uploaded.”, { “OK” } )
end
end
end
– photo uploading requires the “publish_stream” permission
facebook.login( fbAppID, fbListener, { “publish_stream” } )
end[/lua]
Hi Salvador, I got this to work I’m my games will post some more information/code tomorrow, I the mean time you need to check the keyhash your using if it’s on a Android
Ps I didn’t realise you can use the link asset… Try it without the link (or add a correct url) see if it works
–link = "http://roedangames.net"
Hi Salvador, here is my code:
local facebook = require "facebook"local fbAppID = "\*\*\*\*\*\*\*\*\*\*\*\*\*" function onLoginSuccess() attachment = { message = "I have achieved ".. score .. " text......", source = { baseDir=system.DocumentsDirectory, filename="myfile.png", type="image" } } facebook.request( "me/photos", "POST", attachment ) end function fbListener( event ) if event.isError then native.showAlert( "ERROR", event.response, { "OK" } ) else if event.type == "session" and event.phase == "login" then onLoginSuccess() elseif event.type == "request" then local function onComplete( event ) if "clicked" == event.action then local i = event.index closeloading() if 1 == i then end end end native.showAlert( "Success", "Your Score has been uploaded.", { "OK" }, onComplete ) end end end facebook.login( fbAppID, fbListener, { "publish\_stream" } )
ps make sure you have thins in you build.settings :
android ={ usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", }, }, iphone = { plist = { CFBundleVersion = "\*\*\*\*\*", CFBundleShortVersionString = "\*\*\*\*\*", CFBundleDisplayName = "\*\*\*\*\*", CFBundleIdentifier = "\*\*\*\*\*", UIStatusBarHidden = true, UIPrerenderedIcon = false, -- set to false for "shine" overlay UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon@2x.png", "Icon.png", "Icon-xhdpi.png", "Icon-mdpi.png", "Icon-ldpi.png", "Icon-hdpi.png", "Icon-120.png", "Icon-76@2x.png", "Icon-76.png", "Icon-72@2x.png", "Icon-72.png", "Icon-60@2x.png", }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work FacebookAppID = "\*\*\*\*\*", CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXX", -- replace XXXXXXXXX with your facebook appId \*\*LEAVE THE 'fb' AT THE START\*\* } } } } }
Hi,
I attempted to implement your code but I receive same error as before.
Did you implement it on iOS or Android? It seems to work properly on iOS but not on Android.
I also noticed that if you use social plugin for Twitter on Android, the photo posting via system.DocumentsDirectory, it didn’t work (the post doesn’t contain any image).
Thanks,
g
Hi I don’t know about the social plugin as I’m not using it, my code work fine on ios and Android, as it’s not working on your Android I suggest you have a look at your key hash you use in your Facebook app setting this is probably the reason for it not working. What key chain are you using to compile the Android application?