Open Facebook App from Within Another App

Discussion in 'iOS Programming' started by RagingGoat, Nov 8, 2012.

  1. RagingGoat macrumors 6502

    Joined:
    Jun 21, 2010
    #1
    I have an app that has a table view with a list of Facebook pages. When the user selects a row it should open the page in the Facebook app and if the user doesn't have the app installed it will open the page in Safari. It will open in Safari fine but when it opens in the FB app it says "The page you requested was not found". I'm doing the same thing with some Twitter pages and all of those work just fine.

    Here is my FB code:

    Code:
    NSURL *facebookURL2 = [NSURL URLWithString:@"fb://profile/403322143067515"];
        NSURL *safariURL2 = [NSURL URLWithString:@"https://facebook.com/KYRoadsideFarmMarkets"];
    
    
    if (indexPath.row == 1)
        {
            if ([[UIApplication sharedApplication] canOpenURL:facebookURL2])
            {
                [[UIApplication sharedApplication] openURL:facebookURL2];
            }
            else
            {
                [[UIApplication sharedApplication] openURL:safariURL2];
            }
        }
    
    
    Any ideas?
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    How do you know if the Facebook URL is correct? ;)
     
  3. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #3
    I got the Facebook ID from the page so I know it's right. I've also tried fb://page/403322143067515 but that didn't work, plus everything I've found online suggests using profile anyway.
     
  4. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #4
    I've fixed it. Apparently the Facebook IDs I had were wrong.
     
  5. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #5
    hehe :) You can set this thread as resolved :)
     

Share This Page