Dialog 'apprequests' friend invites send OK but never get through. (iOS) - ios

I'm having problems getting friend invites working. They seem to be being sent OK (I don't get any errors from the iOS delegates) but the invites never appear on the receivers FB account. I'm using iOS SDK and logging in with test users. The code I'm using to create the invite dialog is:
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
[dict setValue:#"Accept my invite" forKey:#"message"];
[_facebook dialog:#"apprequests" andParams:dict andDelegate:self];
This brings up the dialog where I can select friends to invite. When I hit Send the dialog vanishes and no errors are returned. Problem is that the invites are never received by the people I send them to.
I have set my canvas url, so according to other posts on SO everything should be working fine... but they are not.
Thanks for any suggestions.

Actually this is explained in Requests documentation:
User to User Requests are only available for Canvas apps, not websites, as accepting a request will direct the user to the Canvas Page URL of the app that sent the Request.
Same stated about App to User requests as well.
This is probably not only because Canvas URL, but also application type (I guess it shouldn't be native to display request)
In fact requests are sent but users not able to see 'em. You can access requests (via Graph API) for users of your application and display 'em in your app.

Solution: (Sending Invitations, getting ID in response, but no Notification alert or request on facebook.......).
Please first remove all requests from your facebook. Then send invitation.(If getting ID in response), then it will be shown 100%.
This is a problem with facebook, it doesn't shows latest requests on top if max notifications/requests reached.(It hides new notifications/request).

Related

Prefilled data in facebook web dialog

Is there any way i can prefill any string in FBWebDialog? Any workaround would do,I am aware facebook has deprecated the message parameter from their sdk.
My scenario is user clicks on a facebook contact
FBWebDialog opens and then the message gets prefilled with some text instead of a blank textfield.
any help would be appreciated
Thanks
Okay, from the comments it sounds like you want to post on the user's wall. Here is a method that is available in the FB SDK that pulls up a share dialog within your app and supports pre filled text
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self initialText:#"Initial text" image:nil url:nil handler:nil];
Example with pre filled text:
Which type of dialog are you opening? (Sounds like the Send dialog, if you want to send a Facebook message.)
I do not think it is possible to even send a message directly to a user from iOS. When performing the following I get the error "This dialog is not available on this device"
[FBWebDialogs presentDialogModallyWithSession:nil dialog:#"send" parameters ...
iOS FB SDK WebDialog reference shows the following methods:
+ presentRequestsDialogModallyWithSession:message:title:parameters:handler:
+ presentRequestsDialogModallyWithSession:message:title:parameters:handler:friendCache:
Those seem to support pre-populating the message field. They only support apprequests though (not messages) and whether the message is even attached is a bit unknown (all I saw when testing was "User wants you to try App", not the actual string I set).
The javascript API (which could maybe be pulled up in a webview?) doesn't have a parameter to set the message probably because the Send dialog documentation says:
Facebook messages are a channel for person-to-person communication,
and not for apps to send messages, or encourage people to spam their
friends.
If you just want to post a message/share then you can use a share sheet which looks to support an initial message:
[FBNativeDialogs presentShareDialogModallyFrom:self initialText:#"My text to share" ...

iOS FB SDK Incoming URL for apprequests is missing ref=notif, request_ids, app_request_type

I am using iOS FB SDK (baked in Parse F/W) to send app request invites using
[facebook dialog:#"apprequests" andParams:params andDelegate:nil];]
The requests are being sent correctly and also appear on the invitee's account.
When I click on the request, the Facebook app correctly starts my app.
At this point, I am checking for incoming URL to process and get request_ids etc.
The sample code on FB (http://developers.facebook.com/docs/tutorials/ios-sdk-games/requests/) says the incoming URL should be of following format
fb480369938658210://authorize&expires_in=3600&access_token=xyz&target_url=http://m.facebook.com/apps/friendsmashsample?fb_source=notification&request_ids=abc&ref=notif&app_request_type=Duser_to_user
However, I am receiving it like this
fb123456789123456://authorize?expires_in=86400&access_token=BAADiMgKGSZB8BAD3ZCeZAGNkm7d8tGuNZAKuq5nThbNTdiZA1ZBFcp1bhIKp1cFvwDsOPZCZBIgowSwRkBnZARF5tBsyWHk0yLukZAK8ubNZA4ZCbkyQg619cg9v0SMqsaBzgwNbQZCdPZBSLoYwZDZD&
target_url=http%3A%2F%2Fwww.facebook.com%2Fappcenter%2F123456789123456
So there are missing components here like request_ids, ref=notif etc.
Does anything obvious looks to be missing here?
Please help.
Thanks.
For future users, I had to set up the Mobile Site URL as per this bug filed with Facebook - https://developers.facebook.com/bugs/465760136778889/
Ridiculous, but it works. Hope this is resolved. Not sure why they have this dependency.

Posting Photo to facebook fan page via iOS app by regular non-admin users

I am trying to post a photo to my apps facebook fan page and to the users wall also.
I have been successful to post the photo on the users wall, but failed to post it in the fan pages wall. (The user is not necessarily an admin or page owner, just the regular users. As the fan page has the option of anyone can post to it, it is not mandatory for the user to even like the page first. Right?)
After googling a while, I found this answer. According to it, I need an access_token of the fan page and an album_id to do so. But I can't find any clue about how to get them. So far I have tried this code:
if ([appDelegate.facebook isSessionValid])
{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
resultImage, #"picture",
nil];
[appDelegate.facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self]; // to post on users wall, works fine
NSString *path = [NSString stringWithFormat:#"my/accounts /fan_page_id?fields=access_toke/photos"];
[appDelegate.facebook setAccessToken: FACEBOOK_ACCESS_TOKEN];
[appDelegate.facebook requestWithGraphPath:path andParams:params andHttpMethod:#"POST" andDelegate:self]; // to post on fan page wall, this doesn't work
}
Can anyone help me with this? What am I missing here? Thanks in advance.
UPDATE
According to this answer, a regular user can not post a photo to the fan pages wall from an iOS app but can share the photo on it. Now, my question is, how do I accomplish posting the photo on the users wall and share it on the fan page wall at the same time? Is it possible? How do I share the photo on the fan page wall?
UPDATE 2
This answer and the question says that the regular users can post to a fan page wall via news feed, so i modified my code like this:
if ([appDelegate.facebook isSessionValid]) {
NSMutableDictionary *page_params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"fan_page_id", #"to",
#"Test", #"name",
#"Test", #"caption",
resultImage, #"picture",
nil];
[appDelegate.facebook dialog:#"feed"
andParams:page_params
andDelegate:self];
}
But, I keep getting this ridiculous error message and the app crashes:
-[UIImage length]: unrecognized selector sent to instance 0x24d110
2012-06-06 19:59:03.114 app_name[2739:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x24d110'
What should I do now?
At this point after waiting so long, the question comes in my mind is, is this even possible? If so, how do I accomplish this task? And if not, then what are the alternatives? Please help.
Update 3
Just found that there is a known bug in both iOS sdk and the javascript sdk for posting dialogs in fan page wall. Is this true for image upload too? If anyone has a solution to avoid this bug, please help.
This isn't currently (June 2012) possible because of a bug in the API: https://developers.facebook.com/bugs/206254392780441 has the details.
One workaround is to post to the /feed connection of the page and attach an image to the feed story. That image won't be displayed as large as a proper photo upload, but should work OK.
That bug means that posting to the /PAGE_ID/photos connection of a Page using a User access_token will incorrectly upload the photo to the user's /photos connection instead.
Posting to a page's /photos connection will work as expected when using the Page's access_token; the photo will appear on the page's photos page, on the page's timeline, and attributed to the Page itself (i.e 'from' the page)
If your app is specifically for adding content to a page, and has a server-side component, another workaround to get the photos from a user onto the page is to have the users supply a photo to you via your own interface (i.e upload it from the user's device to your server), and use one of the page admins' access_tokens to get a Page access_token and make the upload that way.
Instead of using dialog, you can ask user to grant permission - publish_stream
(since there is a bug in dialog component, otherwise its not required)
Then you can post on a page wall (assuming page allows in page settings).
You can try using graph api explorer. You can change the page id and test by granting above permission in extended permission tab.
Note
One more thing you should remember is, you cannot send image data in picture parameter. You should provide link to the Image.
I would simply try to address the exception error. It is possible to post to your fan page news feed. It is NOT possible to post as the fan page itself, as that would require authentication (thus the access token requirement.. you have to be logged in as that user to post as them). #Igy already address this above.
However, you do not have code for where you are using the image picker to get the image. The exception you are getting is because you are trying to check the length on a UIImage object instead of the NSData object (which is what Facebook requires). To convert your image from the picker to data use the snippet below (replace the img variable with your UIImage).
NSData *imgData = UIImageJPEGRepresentation(img, 0);
// Now call to length by facebook SDK will work and the exception will not fail
NSLog(#"Size of Image(bytes):%d",[imgData length]);
I think you are using wrong argument for posting the photo
You should should use #"url" instead of #"picture"
I am not sure with this, but it might work .
I to had the same problem in javaScript , which was solved .
Please view here for referring to my problem

Facebook IOS SDK Frictionless Requests

There appears to be no way of setting frictionless requests as on for facebook ios sdk. For Javascript inplementations this can be done in the fb.init method.
The only other reference to my problem is Facebook Requests Dialog: Frictionless Requests in native iOS app possible? where it states that frictionless just works when not in sandbox mode.
Has anyone else found this to be the case?
This call enables frictionless requests:
[facebook enableFrictionlessRequests];
But it is not enough to prevent all dialogs from appearing briefly. Since the frictionless recipient cache is by default not loaded until the first dialog appears. Once the first dialog appears, the frictionless recipient list will be loaded and subsequent dialogs won't appear. However, you can call
[facebook reloadFrictionlessRecipientCache];
after a successful login to have the frictionless recipient cache ready before the first dialog appears.
Franco
Frictionless requests can be turned on by setting the "frictionless" parameter of the apprequests dialog to "1". For example;
// create a dictionary for our dialog's parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity: 7];
// set the frictionless requests parameter to "1"
[params setObject: #"1" forKey:#"frictionless"];
// ... add other parameters ...
// show the request dialog
[facebook dialog:#"apprequests" andParams:params andDelegate: nil];
I think this also answers Frictionless Requests on iOS - how?
In newer version (2/25/2012 and newer) of the facebook-ios-sdk, there is a new FBFrictionlessRequestSettings which you can enable once, and then all future apprequests will automatically be frictionless. So when your app starts, you should do:
[facebook enableFrictionlessRequests];
I prefer this over manually setting the #"frictionless" key to 1 because when you send an apprequest, you will still briefly see the FBDialog pop up and then disappear. If you do 'enableFrictionlessRequests', Facebook.m will automatically set the 'isViewInvisible' param for you and prevent the FBDialog from flashing.
Now with the Facebook iOS SDK 3.2.1, you can use frictionless requests without using the deprecated headers. Please check out the BooleanOGSample for implementation detials.

iOS Facebook api, apprequests sent but not receiving?

I'm currently working on an iOS app, and I use apprequests to bring up the dialog to send request. I can see everything working fine (I got the dialog complete thing) but user is not getting the request! I'm working with a test FB app (not public), I'm thinking if there's something I'm missing on setting up the FB app? Or is there a specify permission I have to enable?
Here is a little piece of my code:
-(void)appRequestsWithMessage:(NSString )message {
NSMutableDictionary params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, #"message", nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
}
To allow App Requests to be shown in Facebook, you have to enable "App on Facebook" in Apps Settings and supply a "Canvas URL" and a "Secured Canvas URL".
Have you added the receiving user as a tester on your Facebook app admin page? As long as you're in sandbox mode, only users added as testers (or any other position) can see, interact with and receive requests from our app.
Check the settings page for your app.

Resources