0

I upload the video on facebook.

I also refer this Facebook iOS 3.1 sdk login with publish permission callbacks for facebook error.

when I login with Facebook Application or from my app, the facebook permission popup (read and publish permission both) is open and no error occurred (video upload successfully).

enter image description here

But after that I login from Setting -> Facebook of iPhone then first it ask for read permission in alertview not open in facebook permission popup. (it is shown in following image) and after that it gives following error. enter image description here enter image description here

error->_userInfo: description is in nslog

Printing description of error->_userInfo:
{
    "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 \"The Facebook server could not fulfill this access request: no stored remote_app_id for app\" UserInfo=0x234a76b0 {NSLocalizedDescription=The Facebook server could not fulfill this access request: no stored remote_app_id for app}";
}

Code for this

-(IBAction)btnFacebookShareClick:(id)sender {
    [self StartSpinner];
    if (![self openSessionWithAllowLoginUI:YES]) {
        [self showLoginView];
    }
}

- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState)state error:(NSError *)error {
    switch (state) {
        case FBSessionStateOpen: {
            if (self != nil) {
                [[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
                    if (error) {
                        //error
                    }else{
                        dispatch_async(dispatch_get_current_queue(), ^{
                            [self openSessionForPublishPermissions];
                        });
                    }
                }];
            }
            FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
            [cacheDescriptor prefetchAndCacheForSession:session];
        }
            break;
        case FBSessionStateClosed: {
            [self StopSpinner];
            UIViewController *topViewController = [self.navigationController topViewController];
            UIViewController *modalViewController = [topViewController modalViewController];
            if (modalViewController != nil) {
                [topViewController dismissViewControllerAnimated:YES completion:nil];
            }
            //[self.navigationController popToRootViewControllerAnimated:NO];

            [FBSession.activeSession closeAndClearTokenInformation];

            [self performSelector:@selector(showLoginView) withObject:nil afterDelay:0.5f];
        }
            break;
        case FBSessionStateClosedLoginFailed: {
            [self StopSpinner];
            [self performSelector:@selector(showLoginView) withObject:nil afterDelay:0.5f];
        }
            break;
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter] postNotificationName:SCSessionStateChangedNotificationCamera object:session];

    if (error) {
    //here error occurred ...
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Error: %@", [CameraViewController FBErrorCodeDescription:error.code]] message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    }
}

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [[NSArray alloc] initWithObjects: @"email", nil];
    return [FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}

-(void)openSessionForPublishPermissions {
    if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
        NSArray *permissions = [[NSArray alloc] initWithObjects: @"publish_actions", nil];
        [FBSession.activeSession reauthorizeWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error) {
            if (!error) {
                [self uploadVideoOnFacebook];
            }
            else {
                NSLog(@"%@",error);
            }
        }];
    }
    else {
        [self uploadVideoOnFacebook];
    }
}

-(void) uploadVideoOnFacebook {
    NSURL *pathURL;
    NSData *videoData;

    if (intWhenPushView == 2) {
        pathURL = [NSURL fileURLWithPath:self.strUploadVideoURL];
       videoData = [NSData dataWithContentsOfFile:self.strUploadVideoURL];
    }
    else {
        pathURL = [NSURL URLWithString:self.strUploadVideoURL];
        videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.strUploadVideoURL]];
    }

    NSString *strDesc;
    if ([txtCaption.text isEqualToString:@"Write a caption..."]) {
        strDesc = @"";
    }
    else {
        strDesc = txtCaption.text;
    }

    NSDictionary *videoObject = @{@"title": @"Share60",@"description": strDesc,[pathURL absoluteString]: videoData};
    FBRequest *uploadRequest = [FBRequest requestWithGraphPath:@"me/videos" parameters:videoObject HTTPMethod:@"POST"];
    [self.view setUserInteractionEnabled:NO];

    [uploadRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error)
            [AJNotificationView showNoticeInView:self.view type:AJNotificationTypeGreen title:@"Video uploaded successfully" linedBackground:AJLinedBackgroundTypeAnimated hideAfter:3.0];
        else
            [AJNotificationView showNoticeInView:self.view type:AJNotificationTypeRed title:@"Video uploaded error" linedBackground:AJLinedBackgroundTypeAnimated hideAfter:3.0];

        [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(popViewAfterMKInfo) userInfo:nil repeats:NO];
    }];
}

please give suggestion...and also thanks in advance.

any help would be greatly appreciated.

Community
  • 1
  • 1
DharaParekh
  • 1,745
  • 1
  • 10
  • 17

1 Answers1

0

Please check in the device settings section is there any user is logged in or not and if there is an user logged in then check the permission is accessable or not in device settings->faccebook

Divyam shukla
  • 2,028
  • 12
  • 18