4
votes

Working with iOS Facebook SDK 3.0, it needs to define FacebookAppID and the related URL Scheme with it on the info.plist of the app. I want to define these remotely (request to my own server for app id). So 2 different questions:

  1. Can I alter info.plist of the app in runtime? Or can I define FacebookApID and URL Scheme in another plist where I can alter the plist or even create a new custom plist file?
  2. Is there another way to define URL Scheme and App ID, other than using info.plist for Facebook SDK 3.0 ?
2

2 Answers

14
votes

1.1 No you cannot alter the Info.plist file at runtime.

1.2 No you cannot load another plist file to override settings in Info.plist.

2.1 Yes, you can define FacebookApID without altering Info.plist file, by calling [FBSettings setDefaultAppID:@"Your Facebook App ID"]; See the source code of FBSettings.h in Facebook iOS SDK.

2.2 No, URL Scheme must be defined in Info.plist so iOS can recognize it. I believe that the URL Scheme is read by iOS when installing your app, and it is cached elsewhere in system. Even if you can alter your Info.plist, the system won't pick up your new URL Scheme. But don't worry, there's a workaround for Facebook authentication without using URL schemes! We can force the Facebook iOS SDK to use UIWebView for login, see this stackoverflow question.

2
votes

This is not possible, for multiple reasons:

  1. You are not allowed to modify you iOS app's info.plist file at runtime.
  2. You should have a Facebook app running that you cant get the ID from long before you attempt to ship your app. How are you testing the app right now?
  3. The Facebook app ID is tied to the URL scheme the app uses to complete Facebook's OAuth flow. An iOS app's URL schemes are defined in the info.plist, which, again, you can't change.
  4. Being able to arbitrarily set the Facebook app ID is somewhat of a security issue, as it would make it trivial to pose as someone else's Facebook app.

These are just a handful I could think of off the top of my head, I'm sure there are many more.