3

I want to show a progress bar while my iPhone app is uploading an image to Facebook. Is it possible?

Can I do it with every FBRequest that I make? I also use FBRequest to check extended permission and sometimes takes a lot of time.

Thank you.

4
  • Did you ever solved this progress bar thing? If you did can you please share your solution? Aug 2, 2011 at 9:56
  • NO, I'm sorry. I didn't find a solution.
    – VansFannel
    Aug 2, 2011 at 11:25
  • 1
    I did - if you are still interested :) Aug 2, 2011 at 11:35
  • Yes, I'm still interested. Could you please add an answer to my question explaining your solution? Thanks.
    – VansFannel
    Aug 2, 2011 at 12:59

2 Answers 2

6

For the progress bar there is a little hack you can do. In the FBRequest.h file add this line in the FBRequestDelegate protocol:

- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;

After that in the FBRequest.m file add this function:

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
    if ([_delegate respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
        [_delegate request:self didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
    }
}

Now your delegate will receive a message every time more data it's posted to the server. So basically if you implement this into your delegate you should see some activity in your log:

- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
    NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
}

Let me know if you have any problems hacking this into the current Facebook SDK.

1
  • Can you give me a hand implementing this in the latest SDK 3.1?? Thanks!
    – Jan
    Dec 20, 2012 at 3:48
0

You can't know when it gonna log you in but you can put an UIActivityIndicatorView. You start it when you click on publish button and you end it when you enter the 'didConnect' method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.