Facebook iOS SDK - FWWebDialogs not rendering message - ios

I'm using the Facebook SDK in an iOS app. I'm logging in fine, pulling in friends lists, etc.
I've added code to send a request:
[FBWebDialogs
presentRequestsDialogModallyWithSession:session
message:#"Message"
title:#"Title"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
// view cleanup here
}];
The session is the FBSession stored in the class handling login. The params are suggestions, an array of friends to include. The issue described below occurs equally if params is nil (in which case the list shows all friends).
When I call the dialog, this is what appears:
Note that the "Message" text is missing, as is the entire Message block shown on the various Facebook documentation pages such as https://developers.facebook.com/docs/ios/ios-sdk-games/requests/.
I'm using Facebook SDK 3.7.1, the latest version as of this posting. The screenshot above is from the Simulator using a Facebook Test User account. The same issues occur on a device using a "real" Facebook account.

I'm seeing the same issue. It appears to be a very recent development, as previously the dialog did show the message preview. I also noticed that the dialog does show the message preview if I specify the 'to' parameter; the message preview is missing only if I omit the 'to' parameter so that the dialog shows all the user's friends. Unfortunately I don't have a solution, but I wanted to share these additional observations if it helps get closer to the solution.
Andrew

Apparently, this is "By Design"!! :(
https://developers.facebook.com/bugs/605575982818621

Related

Login through FB Giving Error iOS Objective-C [duplicate]

Something must have changed recently on Facebook's servers regarding how they process login requests because this used to be working perfectly and suddenly stopped.
(We are using FBSDKLoginManager.loginBehavior = FBSDKLoginBehaviorWeb because of how our app is replicated for multiple brands (one codebase, many apps) and issues we ran into using the native login.)
Anyhow, this is what we see now when we try to present a login webview to the user (before it even lets them attempt to login):
(Not Logged In: You are not logged in. Please login and try again.)
This is the code we are using to present the login view:
NSString *const publish_actions = #"publish_actions";
FBSDKLoginManager* login = [FBSDKLoginManager new];
login.loginBehavior = FBSDKLoginBehaviorWeb;
[login logInWithPublishPermissions:#[publish_actions] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
[FBSDKAccessToken setCurrentAccessToken:result.token];
// ...
}];
Also note that this problem is not specific to iOS. Our Android app is seeing the same thing (and again it used to work fine until just recently).
I was having this same bug... seems as though the issue lies in your info.plist URL Scheme settings: Facebook SDK: app not registered as a URL Scheme
However, adding these leads to the app sending you off to the actual Facebook app for authentication, instead of showing the login modal in your own app.
** UPDATE **
Sorry, I spoke too soon... the above changes will help things out (or change the user flow in ways you don't want), but what really needed to happen (and this is the only thing), was just adding an "iOS Platform" (or other) to your app settings in the Facebook Developer portal. This is what did it for me anyways. :)

Facebook Share Dialog: Permission Error - OAuth "Facebook Platform" "insufficient_scope (#200) Permissions error"

My requirement is here:
Share to Facebook from my app using Open Graph Action - using Share Dialog (because I don't want special dialog for login)
I request publish permission, and upon obtaining it I try to share via Post dialog. Here is the brief code I use:
[FBRequestConnection startWithGraphPath:#"/MY_FB_APP_ID/app_link_hosts"
parameters:paramsForAppLinksHost HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSString * appLinkHostURLID = [result objectForKey:#"id"]; // store this ID in an NSString
if(error)
{
NSLog(#"error = %#", error.description);
}
else
{
[self ShareToFB : appLinkHostURLID]; //Code to share OG story via Share Dialog
}
}];
However, above error gives me this:
com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 200;
message = "(#200) Permissions error";
type = OAuthException;
};
};
The problem with Facebook SDK is that there is so much documentation and almost no support that I haven't got my previous questions answered too (where I was trying to share without permission), and this problem simply doesn't yield.
Somebody please tell - Is having FB app approved by Facebook a REQUIREMENT for this to work perfectly? If so, how does one correctly provide app store ID when the app isn't even live on Apple store? They use it even in code for applinks related permissions (see above).
The crux of the issue is that everything works with developer facebook login perfectly but fails with another FB user. This means that all my plist and everything is OK. However the FB app isn't submitted (and for many valid reasons such as my iOS app is still in development - how can one be expected to submit screenshots and all even before app is live?)
Someone please help...
OK, I figured it out myself - like many other developers.
1 - This error is due to the fact that FB app isn't approved for certain permissions but still trying to use / request that permission from user. publish_action is one such permission.
2 - In order to test this, facebook app developer needs to approve test users from within develolper.facebook.com portal.
3 - This test user is located in your FB app portal under:
a) Status & Review -> Items under Review section
and
b) Roles section.
You (FB app administrator Developer) need to add the user in b), and not a).
Then the user needs to approve your request. And in order to do that, he needs to register himself as FB developer too.
So much for neat documentation...one can easily get lost.
The github samples and all are great, but none of them tells the whole picture.
Alas, they modify their error descriptions instead.

Get invitable_friends Facebook API iOS

I implement an app which need to get list invitable_friends from Facebook. I had researched how to get invitable_friends (have some question like that on stack overflow but I also cannot get any right way to fix it) and also tried but the result always null, I guess the reason is that :The invitable_friends list is only available for games with a Canvas implementation. But I don't know how to integrate Canvas or do somethings else to get the list invitable_friends(sorry, maybe it's a naive way to make a question but I'm not have any experience at this). please let me know the way to get this list(configuration my app on Facebook developer page or do anything).
Here is my code to get list after login success:
[FBRequestConnection startWithGraphPath:#"/me/invitable_friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
NSDictionary *result,
NSError *error
) {
/* handle the result */
NSLog(#"resurl");
}];
The Invitable Friends API is only available to apps classified as Games, which also have a Canvas presence. This API is not available in v1.0. It may be called by mobile games as long as they also have a Canvas presence.
Source: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/invitable_friends
Meaning, it is ONLY possible for games, if your App is NOT a game you can forget about it. And you MUST have a Canvas implementation next to your mobile one. Meaning, you canĀ“t just create a Canvas App that redirects (which would not be allowed), you would have to create a game that actually runs on Canvas too.
Detailed information about Canvas Apps can be found in the docs: https://developers.facebook.com/docs/games/canvas
After many research I found the solution. Into the Basic Setting field of Facebook Developer page
I need to add platform Website:Site URL:https://local.host:3000/ and Facebook Canvas:Secure Canvas URL:https://local.host:3000/. Of course this site is add for dummy app. When you want to public the app will need submit your app for review by Facebook, then you will need a real website.
You can see the answer of #Spundun Here. With those config, now I can get friends list by invitable-friends

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" ...

New iOS SDK 3.0, Posting to a user's wall without deprecated API

I'd like to know if there is a proper way to post a message to a user's wall with the new SDK.
From what I understand there is no way anymore to display a message preview with a dialog view to the user before posting.
I'd rather not using deprecated API. I followed the tutorial for login in with Facebook with the new SDK (importing the Framework etc). When it comes to post a message they ask to import the deprecated Facebook.h header (and its friends...) but it generates lot of compilation errors because some classes are named the same.
Do you people use the deprecated API?
Or do I have to create a custom view myself to display a preview to the user and then use the FBRequest method + requestWithGraphPath:parameters:HTTPMethod: to perform the post "in the background"?
The solution is simple. This worked for me:
We need not import the deprecated headers at all. By using only the latest facebook ios sdk 3.0 following is what you can do.
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"%#/feed",fbid]
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result,NSError *error)
{
NSLog(#"error %# \n\n\nresult = %#",error,result);
}
fbid is the profile id of the user. You can give the friend's profile id in order to post on his wall.
In case you have to post on the user's own wall, you can either give the graph path as #"me/feed" or as stated above (by giving the fbid as the user's profile id)
Hope this helps.
As of Facebook SDK 3.2, it is now possible to display a native dialog with the new classes available in the SDK. Have a look to FBNativeDialogs, FBShareDialogParams and FBOpenGraphActionShareDialogParams.
I ran into the same problem and I couldn't find a way around importing the deprecated headers, like the tutorial says. After importing both the framework and Facebook.h with friends, clean your project to make sure the linker doesn't complain about the same file names.
The apprequests tutorial still explicitly says to import deprecated headers. So I don't think FB wants you to implement your own views. I would assume they had to release 3.0 and posting to wall and apprequests weren't finished, so they now have this hybrid 3.0/deprecated system until they finish the rest.

Resources