Reputation: 1780
I'm trying to post a simple url to facebook from within my Native iOS App. What I do is this:
facebook = [[Facebook alloc] initWithAppId:FB_APP_ID andDelegate:delegate];
then at some point
[facebook authorize:permissions];
at this point my app quits and it gets me to safari and to the permissions page instead of presenting me a login-dialog (inside my app) where I login and then hit post or something an just post to my wall.
I'm pretty sure this is a simple question but since this is the first time I'm doing facebook integration it is a pain for me configuring it and the docs don't help to much.
Any help is appreciated! Thanks!
Upvotes: 1
Views: 1790
Reputation: 10045
If you definitely need to remove redirection to Safari or Facebook app, you should open the FBConnect Facebook.h class and find the following method:
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth {
there you need to state that you do not want to be redirected anywhere, to do that set those two bools to NO
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth {
tryFBAppAuth = NO;
trySafariAuth = NO;
Next, to post something to wall, you have two options. One is broken - the standard facebook dialog window, which will bring the keyboard BEHIND the actual webview once you show any UIAlertView
ANYWHERE in your application, therefore do NOT use it. Instead use your own custom interface with a simple UITextView
area and a push to wall outlet button. Here's the method that you'll need in order to post to wall from your custom view:
- (void)facebookPostToWallWithMessage:(NSString *)message {
sharedInstance.facebookDelegate = delegate;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, @"message", // The status message
nil];
pushMessageRequest = [facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
}
And here's the delegation methods that you'll need in order to inform users that they've posted an update or to inform them that it has failed:
- (void)request:(FBRequest *)request didLoad:(id)result {
if (request == pushMessageRequest) {
NSLog(@"message has been posted, inform delegate");
}
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
if (request == pushMessageRequest) {
//failed to post message, inform delegate
//[facebookDelegate facebookFailedToPostToWallWithMessage:error.localizedDescription];
}
}
Upvotes: 2