简体   繁体   中英

What is NSURL *resultURL when inviting friends through Facebook iOS SDK?

I'm developing an iOS game that will use Facebook requests as part of the user acquisition strategy. I've implemented the request dialog and can already send request to my friends. The callback in Facebook iOS SDK returns 3 objects: FBWebDialogResult result , NSURL *resultURL and NSError *error

My doubt regards the NSURL , which has the following format:

fbconnect://success?request=23269054024361&to%5B0%5D=1453458133453 .

What exactly should I do with this URL? I see it is a URL that passes the recently invited friends IDs.

You can use it for extracting the invited friends IDs. I don't see many other purposes of that.

Since we're talking about it, I'll drop here a method that I use for parsing the URL and getting the invited IDs back.

- (NSArray *)invitedFriendsIdsFromURL:(NSURL *)resultURL {
    NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"to%5B\\d+%5D=(\\d+)"
                                                                            options:NSRegularExpressionCaseInsensitive
                                                                              error:NULL];
    NSArray * matches = [regex matchesInString:resultURL.absoluteString
                                       options:0
                                         range:(NSRange){0, resultURL.absoluteString.length}];
    NSMutableArray * ids = [NSMutableArray arrayWithCapacity:matches.count];
    for (NSTextCheckingResult * match in matches) {
        [ids addObject:[resultURL.absoluteString substringWithRange:[match rangeAtIndex:1]]];
    }
    return ids;
}

I was also looking for another issue related to " invite friends request " but it's completely different than this thread. For your question, you should look into Facebook IOS Invite Request - Deep Linking .

You can do many things with these recipient id's - specially for games either on client or backend host.

  • Give referral bonus or reward to the sender once any recipient joined the game through his invitation request.
  • Keep track of spamming.
  • And any other action required after the "invite request" to update the client or server state.

Hope this helps!

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