Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

facebook

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.

like image 736
gabriel_vincent Avatar asked Dec 28 '25 03:12

gabriel_vincent


1 Answers

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;
}
like image 131
Gabriele Petronella Avatar answered Dec 30 '25 17:12

Gabriele Petronella



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!