Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from Gabro/master

Thanks for contributing. I'm adding the method.
  • Loading branch information...
commit fc81d7ebd224dd2edce5557bcf3bb48d035afeea 2 parents eb32816 + 1eebf91
Lucas Correa authored
Showing with 43 additions and 0 deletions.
  1. +1 −0  SCFacebook/SCFacebook.h
  2. +42 −0 SCFacebook/SCFacebook.m
1  SCFacebook/SCFacebook.h
View
@@ -64,5 +64,6 @@ typedef enum {
+(void)feedPostWithMessageDialogCallBack:(SCFacebookCallback)callBack;
+(void)feedPostWithPhoto:(UIImage*)_photo caption:(NSString*)_caption callBack:(SCFacebookCallback)callBack;
+(void)myFeedCallBack:(SCFacebookCallback)callBack;
++(void)inviteFriendsWithMessage:(NSString *)_message callBack:(SCFacebookCallback)callBack;
@end
42 SCFacebook/SCFacebook.m
View
@@ -274,6 +274,20 @@ -(void)_myFeedCallBack:(SCFacebookCallback)callBack{
self.callback = callBack;
}
+- (void)_inviteFriendsWithMessage:(NSString *)_message callBack:(SCFacebookCallback)callBack {
+ if (_message == nil || _message.length == 0 || _message.length > 255) {
+ [NSException raise:@"Invalid message value"
+ format:@"message cannot be nil, empty or longer than 255 characters"];
+ }
+
+ NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObject:_message
+ forKey:@"message"];
+
+ [_facebook dialog:@"apprequests"
+ andParams:params
+ andDelegate:self];
+ self.callback = callBack;
+}
#pragma mark -
#pragma mark Public Methods Class
@@ -318,6 +332,9 @@ +(void)myFeedCallBack:(SCFacebookCallback)callBack{
[[SCFacebook shared] _myFeedCallBack:callBack];
}
++(void)inviteFriendsWithMessage:(NSString *)_message callBack:(SCFacebookCallback)callBack{
+ [[SCFacebook shared] _inviteFriendsWithMessage:_message callBack:callBack];
+}
#pragma mark -
#pragma mark FBSessionDelegate Methods
@@ -440,4 +457,29 @@ - (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error {
self.callback(NO, [[error userInfo] objectForKey:@"error_msg"]);
}
+- (void)dialogCompleteWithUrl:(NSURL *)url {
+ //Check for request dialog response
+ //format:
+ // to[0]=FRIEND_0_ID&to[1]=FRIEND_1_ID ... &to[n]=FRIEND_N_ID
+ NSRegularExpression * requestDialogRegExp = [NSRegularExpression regularExpressionWithPattern:@"fbconnect:\\/\\/success\\?request=\\d+(&to%5B\\d+%5D=\\d+)*" options:NSRegularExpressionCaseInsensitive error:nil];
+ if ([requestDialogRegExp numberOfMatchesInString:url.absoluteString
+ options:0
+ range:NSMakeRange(0, url.absoluteString.length)] == 1) {
+ NSMutableArray * friendsIds = [NSMutableArray array];
+
+ //Extract the friend ids
+ NSRegularExpression * regExp = [NSRegularExpression regularExpressionWithPattern:@"%5B\\d+%5D=(\\d+)" options:NSRegularExpressionCaseInsensitive error:nil];
+ [regExp enumerateMatchesInString:url.absoluteString
+ options:0
+ range:NSMakeRange(0, url.absoluteString.length)
+ usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
+ NSString * friendId = [url.absoluteString substringWithRange:[result rangeAtIndex:1]];
+ [friendsIds addObject:friendId];
+ }];
+
+ //Return success and the friend ids array
+ self.callback(YES, friendsIds);
+ }
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.