2

After dowloading the Facebook SDK for iOS, I started to play with HelloFaceBookSample. I figured out how to post (on my TimeLine) text or pictures of my choice.

I would now like to be able to send text or a picture as a private message. I saw the friend picker button and code, but I do not quite see how I can pick a friend and then send him or her a given piece of text.

Where should I look at?

Thanks for any tip.

Michel
  • 10,303
  • 17
  • 82
  • 179

5 Answers5

4

I've just discovered from Facebook API and see that it's possible to send direct message to a specific Facebook user by using Message Dialog. Check here for more details: https://developers.facebook.com/docs/ios/share#message-dialog

There's just a limitation: "Because the Message Dialog can only be presented when the native Facebook Messenger for iOS app is installed, the first thing we need to do is check if this is the case by using the FBDialogs canPresentMessageDialogWithParams: method."

Hope that help!

Phien Tram
  • 381
  • 4
  • 8
1

From the friend picker you can get a bunch of FBGraphUser object, which has a username property. If you append @facebook.com to this property, you will get the user facebook email addresses. Now you just write an email to this addresses and the user will get a private facebook message from your facebook account which is registered under your email address.

The only prerequisite that your email address needs to be attached to a facebook account.

flatronka
  • 1,061
  • 25
  • 51
  • This will not work in practice since all messages sent to Facebook users via their @facebook.com address will end up in their "spam" folder (aka. "other") – Thomas Watson Aug 23 '13 at 15:36
  • if the person is your friend then she will get the message as a private message. – flatronka Sep 02 '13 at 14:05
  • That is only if the sender is recognized by Facebook. If you send the mail without involving the user (which is what I imagine this user don't want) this would be very hard if not impossible to spoof - depending of cause of the level of spam protection Facebook have implemented. I haven't tested this thoroughly yet - but some stats would be interesting :) – Thomas Watson Sep 02 '13 at 19:36
0

It is not possible to send a private message via the Facebook SDK for iOS. The Send Dialog is not available for mobile devices.

SAHM
  • 4,078
  • 7
  • 41
  • 77
0

This is not possible now, but there is a work around. You can engage with the user in the public realm and ask them to send you private messages, but you can't send private messages back, only public ones. Of course, this all depends on if the user gives you the correct permissions.

If you have given permission to access a person's friends, you can then theoretically post on that users wall with references to each one of the friends, asking them to publicly interact with you and then potentially privately message you.

Get Friends

#if authenticated
https://graph.facebook.com/me/friends
http://developers.facebook.com/docs/reference/api/user/

Post in the Public Domain

http://developers.facebook.com/docs/reference/api/status/

Get Messages sent to that user (if given permission)

http://developers.facebook.com/docs/reference/api/message/

Refer following : Send private messages to friends

Community
  • 1
  • 1
Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45
0

You can use XMPP protocol for sending private messages. The best helpful framework for it is XMPPFramework - https://github.com/robbiehanson/XMPPFramework Read more here - https://developers.facebook.com/docs/chat/