简体   繁体   中英

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. I have a list where a player can invite his facebook friends to play. 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. 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?

在此处输入图片说明

With the webdialogs method it does not seem to allow custom text send to one specific player. 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
     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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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