I am simply trying to integrate Facebook sharing into my app, my app's end product is a video hence uploading and sharing the final compilation with friends is what i have in mind, I am using native social framework with ACAccount Framework, for my app to work there seems to be weird logic from Facebook that i need to ask for read permission before i ask for publish_stream permission and that they cant be immediately after(read somewhere), my question is where and how should i implement this logic in my code, heres my code
ACAccountStore* accountStore = [[ACAccountStore alloc] init];
NSDictionary *options = @{
ACFacebookAppIdKey: @"My app ID",
ACFacebookPermissionsKey: @[@"user_birthday"],
ACFacebookAudienceKey: ACFacebookAudienceOnlyMe
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
ACAccount * facebookAccount = [accounts lastObject];
NSLog(@"access to facebook account ok %@", facebookAccount.username);
NSData *videoData = [NSData dataWithContentsOfFile:[_fURL absoluteString]];
NSLog(@"%@",[_fURL absoluteString]);
NSLog(@"video size = %d", [videoData length]);
NSDictionary *params = @{
@"title": @"Me being silly",
@"description": @"Me testing the video upload to Facebook with the new system."
};
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:requestURL
parameters:params];
[request addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:[_fURL absoluteString]];
request.account = facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response,NSError * error){
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"response = %@", responseString);
}];
Yes I am missing publish stream permission but i cant seem to figure out where should i put it, this whole code is under one method which is called when user presses a button