-
-
Save nileshpunjabi/24e85b259fd21dc4666c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)fillProfile | |
{ | |
RevMobAds *revmob = [RevMobAds session]; | |
[[FBRequest requestForGraphPath:@"me?fields=id,gender,age_range,birthday"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { | |
if (error == nil) { | |
NSString *gender = [result objectForKey:@"gender"]; | |
if (gender != nil) | |
revmob.userGender = [gender isEqualToString:@"male"] ? RevMobUserGenderMale : RevMobUserGenderFemale; | |
NSNumber *minAge = [[result objectForKey:@"age_range"] objectForKey:@"min"]; | |
if (minAge != nil) | |
revmob.userAgeRangeMin = [minAge integerValue]; | |
NSNumber *maxAge = [[result objectForKey:@"age_range"] objectForKey:@"max"]; | |
if (maxAge != nil) | |
revmob.userAgeRangeMax = [maxAge integerValue]; | |
NSString *birhday = [result objectForKey:@"birthday"]; | |
if (birhday != nil) { | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
formatter.dateFormat = @"MM/dd/yyyy"; | |
revmob.userBirthday = [formatter dateFromString:birhday]; | |
#if ! __has_feature(objc_arc) | |
[formatter release]; | |
#endif | |
} | |
NSString *userID = [result objectForKey:@"id"]; | |
if (userID != nil) { | |
revmob.userPage = [NSString stringWithFormat:@"http://facebook.com/%@",userID]; | |
} | |
} else { | |
NSLog(@"ERROR: %@",error); | |
} | |
}]; | |
[[FBRequest requestForGraphPath:@"me/likes"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { | |
if (error == nil) { | |
NSArray *data = [result objectForKey:@"data"]; | |
NSUInteger n = [result count]; | |
__block NSMutableArray *interests = [NSMutableArray arrayWithCapacity:n]; | |
[data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
[interests addObject:[obj objectForKey:@"name"]]; | |
}]; | |
revmob.userInterests = interests; | |
} else { | |
NSLog(@"ERROR: %@",error); | |
} | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment