Share gifts with FB SDK iOS - share

I am having a problem making gifts (pack of coins, lives, etc). I have been using this guide.
I think I did everything correctly at https://developers.facebook.com/, created the coin type, made the object and used its id.
This is my code for request:
FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
gameRequestContent.message = #"Take this coins";
gameRequestContent.title = #"Choose users";
gameRequestContent.filters = FBSDKGameRequestFilterAppUsers;
gameRequestContent.actionType = FBSDKGameRequestActionTypeSend;
gameRequestContent.objectID = #"386681778192859";
[FBSDKGameRequestDialog showWithContent:gameRequestContent delegate:self];
My question is how I can take a message or a callback from this request at another device. I was looking for a solution at facebook site, but I didn't find anything. In general, is it possible or do I have to make custom server?

Related

In-App Purchase test fails on IOS 4.01, works on iOS 5+

This is driving me crazy.
I'm trying to debug an App that uses In-App Purchase.
I use the following simple piece of code to get my products (I've got only one product):
NSSet *productIdentifiers = [NSSet setWithObject:PRODUCT_ID];
SKProductsRequest *request = [[[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers] autorelease];
request.delegate = self;
[request start];
On devices running iOS5 and above, I get my product back in the response.products property of productsRequest:didReceiveResponse:. I can also place an order (using a test user) on these devices.
On a device running iOS 4.01, I get an empty array in response.products and my product id in response.invalidProductIdentifiers. If I try to ignore the product information and call addPayment: on this device using the same product id, I'm getting SKPaymentTransactionStateFailed in paymentQueue:updatedTransactions:.
Obviously my setup is correct, since things work flawlessly on my iOS5+ devices.
I also checked and tried everything in http://troybrant.net/blog/2010/01/invalid-product-ids/ to no avail.
Any ideas? Do you think it's safe for me to submit the App under this situation?
This right here helped me out when I was debugging a similar problem - http://teewe.com/2011/10/24/ios-in-app-purchase-programming-troubleshooting-guide-continuously-updating/

FBStreamDialog no longer working as expected

I am using an FBStreamDialog to display a custom prompt, capture a text message and then display that message, along with an MP3 file on a chosen Facebook friend's wall. The code has been working fine for the last 6 months in my live app. This week, however, it has stopped working. It can only be the result of a recent change in how Facebook responds to the function calls (I've logged a bug:
https://developers.facebook.com/bugs/344519698917066browse=search_4f611f5d302a37460391579).
Has anyone else encountered this problem and is there an alternative I can use without having to recode the entire FB connection stuff?
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your special message:";
dialog.attachment = [NSString stringWithFormat:#"{ custom string stuff here"}]}", friendName, #" "];
FB support response to this says I should just install a later version of the SDK and that they can find no reference to FBStreamDialog! I think this is poor when app developers have live products.

How to do string formatting in Objective-C?

I am trying to post text from my iPhone app to my wall on Facebook. Everything works fine, however, my problem is that I am not sure how to format the text. I would like to show the user the name, address, city, state, and phone number of the restaurant they are viewing on the app. Here is my relevant code:
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%# got straight A's!\",\"href\":\"http://www.example.com/\",\"caption\":\"%# must have gotten real lucky this time!\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.abc.png\",\"href\":\"http://www.example.com/\"}]}",
_facebookName, _facebookName];
dialog.actionLinks = #"[{\"text\":\"Download GetHalal!\",\"href\":\"http://www.example.com/\"}]";
[dialog show];
}
I would like to show the user the restaurant information in the dialog.attachment variable, such that the output on the facebook wall looks like this:
restaurant.name
restaurant.address
restaurant.city, restaurant.state
restaurant.phoneNumber
My problem is, the text above appears to be in JSON format. The restaurant object is available in the class, and I'd like to include it in the code above, but I don't know how. Can anyone show me how to do this?
Use a JSON library:
https://stackoverflow.com/questions/286087/best-json-library-to-use-when-developing-an-iphone-application
Also, check the Facebook sdk for iOS:
http://developers.facebook.com/docs/guides/mobile/#ios
The accepted answer in this StackOverflow post has the code you need, with JSONfragment:
How to post a message with attachment in Facebook?
(note that, in this case, the library used is http://code.google.com/p/json-framework/ )

How will this code publish an image to a wall using Facebook Connect?

I would like to know what this code does exactly.
- (void)dialogDidSucceed:(FBDialog*)dialog {
//[self doSomethingExciting];
FBStreamDialog *dialog2 = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self;
dialog2.userMessagePrompt = #"Example prompt";
dialog2.attachment = #"{\"name\":\"Facebook iPhone SDK\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\","
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
// replace this with a friend's UID
// dialog.targetId = #"999999";
[dialog2 show];
}
When I run it it asks me if I want to publish on my and my friends walls, but Im not sure how this will look on the walls. Also does it publish to the users walls and then show up in their friends incoming stream, like "most recent" or does it actually post on every friends wall?
Thanks
Yes. You are posting an image to their stream.
Attachment is an escaped sequence of JSON that Facebook will pick up on and attach an image (and it looks like a link as well).
What the user will see is the image/link preconfigured as a wall post, and they will have a text box to enter their own text referred so as User Message Prompt.
Whether or not it shows up on friends streams depends on their settings, but ultimately, this is a news stream post, and thus has the potential to appear on their home page.
An other answer already explained what the code does.
This is just a tip:
Create three fake FaceBook accounts, and connect them together.
Then use them to do your testings. So you will know exactly what happens, and do all the tests you need during development without loosing all your friends.

Submitting a link via iPhone -> Facebook Connect

I'm trying to post links through the iPhone facebook connect without using the feed control. I want to simulate how the publish a story works on facebooks website, where I pass a link, and it returns back an image, story title, and a link. Right now I only know how to use the feed control, but I'm thinking there has to be a way to use possibly stream.Publish or showDialog, just not really sure which..
Anyone have any experience with this?
Use the facebook demo app.
in the SessionViewController, add this to get extended permission:
- (void)askPermission:(id)target {
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"publish_stream";
[dialog show];
}
Then you need a method to publish the stream. They don't say exactly what data to send. But whateer it is you package it in a dictionary. Since it is a URL, a good guess would be an NSString. You can get more from the API page
I found 5 that might work:
Feed.publishActionOfUser
Feed.publishStoryToUser
Feed.publishTemplatizedAction
Feed.publishUserAction
Also there is:
Links.post
But you'll have to figure it out, depending on what you want to do. You also need to kow the key. I picked url
- (IBAction)sendURL:(id)target{
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:urlString forKey:#"url"];
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:#"Links.post" params:args];
}
I've left some args out, but you get the idea. I;m not sure exactly what one you want, so you'll have to research the method calls.
Hope this helps.