Streaming stream using facebook sso - openURL not called

I have successfully applied Single-Sign-On in my iOS 4.3 application. Now I want to post a link to the wall of facebook users, so that when his friends, who also have the application, click on the link, they should be redirected to my application. The way I interpret http://developers.facebook.com/docs/mobile/ios/build/#deeplink is that one of the delegate functions

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url, (pre iOS 4.2) - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation , (iOS 4.2+) 

and that the shared link can be parsed using the [target_link] key. However, I cannot get this to work. I have successfully posted a link to the user feed using:

  NSDictionary* params=[[NSDictionary alloc] initWithObjectsAndKeys:myFacebookAppID,@"app_id", linkToPost,@"link",nil]; [_facebook dialog:@"feed" andParams:params andDelegate:self] 

The message appears in my feed, but when I click on the link, none of the delegate methods mentioned above are called. Should I do something special with the link, I tried adding "fb: myFacebookAppID: //" before the link, but this does not work at all. I didn’t understand something?

My application does not work in the AppStore yet, and there is a field on developers.facebook.com asking me to enter my AppStore ID, can this be a problem? If so, is there a workaround? I want to check how this works before posting my application to the AppStore.

Thank you for your help!

+3
source share
1 answer

You need your facebook app in AppDelegate, for example:

 @interface FacebookAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UINavigationController *navigationController; @property (nonatomic, strong) Facebook *facebook; @end - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.viewController = [[FacebookViewController alloc] initWithNibName:@"FacebookViewController" bundle:nil]; self.facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:(id)self.viewController]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } 

And inside AppDelegate you have to implement:

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [self.facebook handleOpenURL:url]; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [self.facebook handleOpenURL:url]; } 

And if you want to implement the protocol in your class, you need to call facebook:

 FacebookAppDelegate *fbAppDelegate = (FacebookAppDelegate *)[[UIApplication sharedApplication] delegate]; NSArray *permissions = [[NSArray alloc] initWithObjects:@"publish_stream",@"create_event",@"offline_access", nil]; [[fbAppDelegate facebook] authorize:permissions]; 
+4
source

Source: https://habr.com/ru/post/921818/


All Articles