open profile in Facebook app from button

Discussion in 'iOS Programming' started by prello23, Feb 13, 2014.

  1. prello23, Feb 13, 2014
    Last edited by a moderator: Feb 13, 2014

    prello23 macrumors newbie

    Joined:
    Dec 20, 2011
    #1
    i did this but is is not working what am i doing wrong it dose open Facebook app but just
    in news feed?

    Code:
    - (IBAction)ribsafarifacebook;
        {
          NSURL *url = [NSURL URLWithString:@"fb://profile/ribsafari.is"];
          [[UIApplication sharedApplication] openURL:url];
    
        }
     
  2. RagingGoat macrumors 6502

    Joined:
    Jun 21, 2010
    #2
    I'm pretty sure you need the Facebook ID for the profile. Here is how I do it in one of my apps.

    Code:
    NSURL *facebookURL = [NSURL URLWithString:@"fb://profile/114276365276090"];
    
    NSURL *safariURL = [NSURL URLWithString:@"http://facebook.com/kyfarmbureau"];
    
    if ([[UIApplication sharedApplication] canOpenURL:facebookURL])
             {
                 [[UIApplication sharedApplication] openURL:facebookURL];
             }
             else
             {
                 [[UIApplication sharedApplication] openURL:safariURL];
             }
    
     
  3. prello23 thread starter macrumors newbie

    Joined:
    Dec 20, 2011
  4. tacotester1 macrumors member

    Joined:
    Dec 19, 2013
    #4
    awesome thank you i had the same problem it was just accessing news feed!
    thanks!
     
  5. RagingGoat macrumors 6502

    Joined:
    Jun 21, 2010
    #5
    You're welcome!
     

Share This Page