Prefilled data in facebook web dialog - ios

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

Related

How to pass text to 3rd party app in iOS

My app generates some sort of text information.
User presses button like "Share" in my app and after that pops up a windows with a list of installed applications or only apps which can recieve string parameter. After that, user selects, for example, "Mail" app and then it is opened with the new email message and with a given text from my app. Or user selects Skype app and then it is opened with a given text.
How could those scenarios be implemented in iOS?
PS: I already saw similar behavior in Android app (via Intent extras).
UPDATE: I posted the answer below that works for me (via UIActivityViewController) exactly how I need.
There is no single answer that will work for all target apps. You need to research each app and see if it has a facility for receiving info from other apps.
A simple way to do this is to invoke an URL that targets the other app.
For mail, you could invoke a mailto:// URL that composes an email with the text in the desired field(s) (to, cc, bcc, subject, or body.)
If the app supports the iOS document model you may be able to pass it a document to open.
If the target app has a server then you may also be able to connect to the server and send data to it that way. Again, this is not a question you can ask in general. The answer will be different for each target app, and for some apps the answer will be "you can't, because it doesn't have any mechanism to receive data from an outside app."
Android is a different beast with different abilities than iOS. iOS is more of a "walled garden", with very limited access outside of your app.
I found the best solution for me is
- (IBAction)onShare:(id)sender {
NSString *textStr = self.textToShare.text;
NSArray *items = #[textStr];
UIActivityViewController *activity = [[UIActivityViewController alloc]
initWithActivityItems:items
applicationActivities:nil];
[self presentViewController:activity animated:YES completion:nil];
}
It does exactly what I need. It shows popup view with the list of apps which are able to receive text string. Then user can select any of them and controller sends text to it.

FBSdk Share dialog when FB App is not installed

I've been following Facebook code sample "FBShareSample" to create a share dialog,
The example handles the fallback for user without FB App installed.
Everything is working well with FB App but when I get to the fallback the UI in my app look different from the one in FBDemo (navigation bar, buttons etc.)
In addition the friends button is not active.
Am I missing some kind of configuration in my iOS client? Is it somehting that need to be configured on my App page on FB?
I've used Charles to analyse the request and response and the only difference between FB sample code and my code was the userAgent string.
The problem was resolved by removing from the UserAgent parameter the string: " webView", for some reason this specific string caused FB to return a different layout/CSS page when this parameter was present.

Facebook iOS SDK - FWWebDialogs not rendering message

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

Dialog 'apprequests' friend invites send OK but never get through. (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).

Is it possible to create an MMS which contains a url link to launch a local app

I can launch my app if I embed a url in an SMS and then the user clicks on the url from within the message app. I have this all working.
What I would like to be able to do however is send an MMS to the device which contains a number of image(s) and text filling the screen and when the user clicks on the url within the MMS my app is launched same as it is if clicked from within an SMS.
Is it possible to mock this up so I can see it working? i.e. how could I create an MMS containing a working active link to demo a proof of concept (I'm not talking about creating an MMS programatically on iOS, just how to create one containing my app's url to send to the device)?
Edit: This answer was written under the assumption that implementation details were required for the URL handling part. I'll leave the technical details here for future Googlers.
Here is a link to a forum thread which seems to indicate you can't send MMSes from the iPhone programmatically (I know you said you didn't want to know this anyway, but it's here for completeness). The suggestion is to use a message provider's MMS gateway directly (e.g http://www.smsglobal.com).
Instructions on how to get a hyperlink into an MMS are here. You can just write it in plain text, or use an anchor: <a href="myapp://"> Not 100% sure the iPhone will properly parse those anchor tags in an MMS though.
Read this article. The gist is that you add a "URL types" row to your Info.plist and set it to any valid protocol, say myapp, and then a user opens a link in an MMS to a myapp URL. Article excerpt:
myapp://
myapp://some/path/here
myapp://?foo=1&bar=2
myapp://some/path/here?foo=1&bar=2
The iPhone SDK, when launching the application in response to any of the URLs above, will send a message to the UIApplicationDelegate.
If you want to provide a custom handler, simply provide an implementation for the message in your delegate. For example:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
// Do something with the url here
}

Resources