Posting game request to facebook friend is failing

42 views Asked by At

I want to send game request to my facebook friends. Following code sends invite requests if the receiver hasn't had the app installed.

I have gone through every documentation there is (though there is not a lot) and I am not sure what could be the error here. Following is the piece of code:

void FacebookInterface::postGameRequest(std::string title, std::string message, std::string pids,
                                        std::string dataJson, int friendType, int inviteType)
{
    FBSDKGameRequestDialog *gameReq = [[FBSDKGameRequestDialog alloc] init];
    if ([gameReq canShow]) {
        gameReq.content =[[FBSDKGameRequestContent alloc] init];
        gameReq.content.data = [NSString stringWithUTF8String:dataJson.c_str()];
        gameReq.content.message = [NSString stringWithUTF8String:message.c_str()];
        gameReq.content.title = [NSString stringWithUTF8String:title.c_str()];
        
        GameRequestDelegate* delegate = [[GameRequestDelegate alloc] init];
        int count = 0;
        if (!pids.empty()) {
            NSArray* receipients = [[NSString stringWithUTF8String:pids.c_str()] componentsSeparatedByString:@","];
            gameReq.content.recipients = receipients;
            count = (int) [receipients count];
            delegate.toList = pids;
            delegate.count = count;
        } else {
            gameReq.content.filters = FBSDKGameRequestFilter::FBSDKGameRequestFilterAppNonUsers;
            delegate.count = 0;
        }
        
        delegate.friendType = friendType;
        delegate.inviteType = inviteType;
        gameReq.delegate = delegate;
        gameReq.frictionlessRequestsEnabled = YES;
        FabricAnswersInterface::getInstance()->logEvent(title, std::to_string(friendType), count);
        [gameReq show];
    }
}
0

There are 0 answers