Search code examples
iosfacebookfacebook-loginfacebook-ios-sdkurl-scheme

Facebook iOS SDK 4.2: Invalid URL Schemes for Multiple App Environments


I need to use the same Facebook App ID for my staging and production builds. I've defined the URL schemes suffix in my app .plist file and configured the dashboard with the required Bundle Id and URL schemes ,following exactly as sharing an app ID across Apps doc.

Dashboard's URL scheme suffix:

enter image description here

App-Info.plist:

enter image description here

The thing is , I am able to login with Facebook on my staging build properly but when I try to login on production build, it crashes and breaks at the following:

enter image description here

I've tried some of the almost similar solutions, but none of it is working for me. Can someone point me in the right direction?


Solution

  • Got it solved. As it turns out, I can only define one FB URL Scheme per scheme. I also forgot to define FacebookURLSchemeSuffix. So, what I did is, I use user-defined setting to alternate between staging and production build. Here's how I did it.

    1. Go to Targets > Build Setttings and add user-defined setting.

    enter image description here

    Then, I set my user-defined values(FB_SCHEME) to staging for staging build and vice versa.

    1. In my App-info.plist file. I set my FacebookURLSchemeSuffix and URL scheme to the following:

    enter image description here enter image description here

    Now, whenever I switch between schemes, it will set the value of ${FB_SCHEME} to production or staging. That's it.