0

I am having a problem getting Facebook events in the Facebook app. For example, to open an event with the url "https://www.facebook.com/events/1743847059178738/," I would use the following code:

 let facebookURL = NSURL(string: "fb://event/1743847059178738")!
    if UIApplication.sharedApplication().canOpenURL(facebookURL) {
        UIApplication.sharedApplication().openURL(facebookURL)
    } else {
        UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)
    }
}

It will open the Facebook app, but no matter what event I attempt to display I get a screen saying "Unable to load event. It may have been cancelled." I have tried substituting the Facebook URL of an event for that of a profile (e.g., string: "fb://profile/100005906912309") and it works just fine. Am I mistaken in assuming that the numbers at the end of the event's URL are the same as the event's numeric ID?

kamisama42
  • 595
  • 4
  • 18

2 Answers2

1

So I figured out that I could bypass the whole "fb://event..." bit and just go with:

UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)

I assumed this would open the link in Safari, but it automatically opened in Facebook in iOS 8.

kamisama42
  • 595
  • 4
  • 18
1

I'm sorry for the late answer. I'd prefer to write this as comment, but I'm not able to.

First, nice work around. I think it is a perfect fallback if the fb:// scheme fails as it shown in code shared with your question. I've spent a lot of time trying to resolve the same issue. What I've found is that fb://event/{event-id} is no longer supported and it was replaced with fb://event?id={event-id}.

I've used this post as a reference.

Community
  • 1
  • 1
apetrov
  • 430
  • 5
  • 16