简体   繁体   English

如何使用iOS facebook-graph-api将自定义消息发送给一个朋友?

[英]How to send custom message to one friend using iOS facebook-graph-api?

I have a philosophy multiplayer question-answering app that allows players to play against each other answering questions about philosophy and ethics. 我有一个哲学多人问答应用程序,允许玩家相互竞争,回答有关哲学和道德的问题。 For signup i allow facebook-login. 对于注册,我允许Facebook登录。 I have a list where a player can invite his facebook friends to play. 我有一个列表,玩家可以邀请他的facebook朋友一起玩。 Its done with a request to the app-backend with all players friends, and return which have installed the app. 通过与所有玩家朋友向应用程序后端的请求完成,并返回已安装应用程序的用户。

For those who dont yet have installed the app, i want to let the player invite them to install the app. 对于尚未安装该应用程序的人,我想让播放器邀请他们安装该应用程序。 I haven't found a way to do this with iOS graph API. 我还没有找到使用iOS图形API的方法。 Is it possible when a player taps a friend (i have the fbID), to send a message with some custom text and a link to download the app? 当玩家点击一个朋友(我有fbID)时,是否可以发送带有一些自定义文本和链接以下载该应用程序的消息?

在此处输入图片说明

With the webdialogs method it does not seem to allow custom text send to one specific player. 使用webdialogs方法时,似乎不允许自定义文本发送到一个特定的播放器。 And that method opens a new window with friend selection. 然后该方法将打开一个带有选择好友的新窗口。 I don't need that as the user allready has selected a friend to invite. 我不需要,因为用户已经选择了一个邀请好友。 Is there a way to use FBWebDialogs to do this, or any other method in the Facebook iOS API? 有没有办法使用FBWebDialogs来做到这一点,或者有Facebook iOS API中的任何其他方法?

[FBWebDialogs
     presentRequestsDialogModallyWithSession:nil
     message:@"Learn how to make your iOS apps social."
     title:nil
     parameters:nil
     handler:nil]

The way to do this is to set up a simple XMPP server on your server and send it using their XMPP login which you can get with the following code snippet. 这样做的方法是在服务器上设置一个简单的XMPP服务器,并使用其XMPP登录名发送该服务器,您可以通过以下代码段获得该登录名。

if (![FBSession.activeSession.permissions containsObject:@"xmpp_login"]){
        [[FBSession activeSession] requestNewReadPermissions:@[@"xmpp_login"] completionHandler:^(FBSession * session, NSError * error){
            if (!error){
                [self functionThatCommunicatesWithServerAndSendsXMPPLoginInformation];
            } else {
                // handle error
            }
        }];
    } 

There are some nice frameworks that make XMPP really easy to implement on a simple level, such as SleekXMPP for python/django. 有一些不错的框架使XMPP真正易于在简单的级别上实现,例如适用于python / django的SleekXMPP。

It's definitely a little work to do this, but probably much more effective. 这样做绝对是一件小事,但可能会更有效。 Just don't spam. 只是不要垃圾邮件。

For more guides (although I think a little outdated): 有关更多指南(尽管我认为有些过时):

Facebook chat framework for iphone sdk iPhone SDK的Facebook聊天框架

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM