Multiple Apps using the same Facebook app

Hey, Andrew @aukStudios, thank you for sharing your finding in detail.  Yes, I see this happening:

1a)  I install myapp and sign in to FB (before installing myapppro.)  FB sends me back to myapp.  All is well.

1b)  I install myapppro and sign in to FB (after myapp is already installed.)  FB sends me back to myapppro.  All is well.

1c)  Connecting to FB from either of the app returns to the correct app.

However…

2a)  I install both myapp and myapppro before signing into FB from either of them.

2b)  I then start myapppro and sign in to FB… FB sends me back to myapppro – which is perfectly fine.

2c)  I then start myapp and sign in to FB… FB sends me back to myapppro, and I can not sign in to FB from myapp at all.

I think the chance of this issue to cause headache is rather slim.  Most likely, users will choose one app over the other and wouldn’t have both app installed.  And if they do, most likely, they’d sign in to FB from first one before they install the second one, which would not trigger this strange bug.  So, for now, I’m going to table this as known issue but not worry too much about it.

Naomi

Hi Naomi,

Interesting, it sounds like what you’re experiencing is similar but not exactly the same as what I’m experiencing.

Either way, I agree, it’s not likely to be a significant issue because, like you said, most users would only have one version installed.  (It’s more of an issue during development and beta testing.)

I confirm the above. Seems to work fine! Please note:

  • You must add multiple bundle id’s. In the “Native iOS App” section of the Facebook App page, you can add multiple bundle ids, e.g. com.mycompany.myappA, com.mycompany.myappB

  • Then in the URL Scheme Suffix part, you put the suffixes, e.g. myappA, myappB that you use in your build.settings file.

Right now, I have TWO iOS apps using one Facebook app. The two apps are ‘mimeticbooks’ and ‘j210’.

This is from my build.settings file (‘x’ obscure my FB codes):

 FacebookAppID = "xxxxxxxxxx42125", CFBundleURLTypes = { { CFBundleURLSchemes = { "xxxxxxxxxx42125", "fbxxxxxxxxxx42125mimeticbooks", } } },

The following are from the Facebook App page:

Bundle ID:

com.mimetic.mimeticbooks    com.mimetic.j210

URL Scheme Suffix:

mimeticbooks   j210

Andrew @aukStudio and @mimetic, thank you so much for sharing your findings.  I’m about to add a pro version of my game.  Please correct me if I got it wrong, but I think this is what I’m hearing how I’m to do this:

build.settings file:

[lua]

FacebookAppID = “xxxxxxxxxxxxxxx”,

CFBundleURLTypes =

{

    {

        CFBundleURLSchemes =

       {

            “fbxxxxxxxxxxxxxxx”,  – for existing app

            “fbxxxxxxxxxxxxxxxmyapppro”,

       },

   },

},

[/lua]

On Facebook App page:

Bundle ID:

com.mycompany.myapp    com.mycompany.myapppro

URL Scheme Suffix:

myapp    myapppro

Edit:  BTW, I kept he iPhone / iPad App Store ID that belongs to “myapp” (not the new App Store ID I created for “myapppro”) on the FB App page.  I hope that’s how it should be… because it doesn’t look like I can add multiple App Store IDs.

Edit 2:   It looks like it’s working – so I think I got it right.  Cheers.

Naomi

Hi Naomi,

Actually your post is very timely, because I was just looking at this myself again, and now it no longer appears to be working for me (or maybe it never was, and I just didn’t test it enough!).

Here’s what I’m experiencing now.  If only one of my versions is installed on the device, then when it logs into facebook, it gets re-opened successfully after the login process.  But, if two versions of the app are installed, then regardless of which one initiated the login process, only one of them ever gets re-opened.  This appears to be the case regardless of which order I install them or run them.

I’m curious if you try every use case (order of installation, order of launching, order of facebook login), whether it always works?

  • Andrew

Hi Andrew, here’s what I’m seeing so far with mine (on iOS device):

  1.  On my device, I already have myapp installed, and myapp has already logged in to FB before.  (This was done before myapppro ever existed – meaning, I did not log in to FB from myapp after myapppro was added to FB.)

  2.  I installed myapppro to the same device.  Now I have both myapp and myapppro on this device.

  3.  I launched myapppro and then tapped on a button that connects to FB.  FB window indicates that my device (and my FB user) has already authorized this app, and all I had to do was OK it to proceed.

  4.  It retrieved data that myapppro requested from FB, and myapppro works as expected.

  5.  I hit home button and exit myapppro.

  6.  I tap on myapp icon, and it resumes myapp from a suspended state.

  7.  I tap on a button that connects to FB, and it simply processes the request and retrieves data that myapp requested, and myapp works as expected.

So… it looks like to me that myapp and myapppro are working with FB properly.

I wonder what might be the steps you took.  Mind if you share your test process with step-by-step description and indicate where things go wrong?  I’d like to know if mine would come across the same issue if I test differently.

Thanks,

Naomi

Thanks Naomi for writing this out in detail and precisely.  What you’ve said so far isn’t inconsistent with what I’ve experienced.  I think the difference is that, in steps (6) and (7), your myapp is already suspended and already logged into facebook.  Could you try the following instead?

  1. Deauthorize your app on your personal facebook account (under Account Settings), to mimic a user who is getting it for the first time

  2. Force close both of your apps, and then restart them so that each one is running

  3. In one of your apps, do an action that causes your app to login to facebook.  Your app will suspend, and you’ll be brought to facebook’s app authorization screen (either in the facebook app or in Safari).  When you’re done, your app should resume

  4. Did it take you back to the right version of your app in step 3?  If so, repeat steps 1-3, but in step 3, use the other version to login to facebook.  Does it take you back to the right version this time?

For me, it seems that I’m only ever taken back to one of my versions, never the other one.

  • Andrew

I’m finding that whichever version I installed most recently is the one that will open when the facebook authentication wizard is completed or canceled.  I think this basically means that the second entry in CFBundleURLSchemes, which includes the suffix, probably isn’t doing anything.  Instead, what’s probably happening is that both versions have the same URLScheme (of the form fbxxxxxxxxxxxxxxx), and iOS simply takes the one that was most recently installed (i.e., that installation overrides any apps that previously registered for that URLScheme).

This seems to be the case regardless of whether the app that is being opened is in a suspended state or starting fresh.

Hey, Andrew @aukStudios, thank you for sharing your finding in detail.  Yes, I see this happening:

1a)  I install myapp and sign in to FB (before installing myapppro.)  FB sends me back to myapp.  All is well.

1b)  I install myapppro and sign in to FB (after myapp is already installed.)  FB sends me back to myapppro.  All is well.

1c)  Connecting to FB from either of the app returns to the correct app.

However…

2a)  I install both myapp and myapppro before signing into FB from either of them.

2b)  I then start myapppro and sign in to FB… FB sends me back to myapppro – which is perfectly fine.

2c)  I then start myapp and sign in to FB… FB sends me back to myapppro, and I can not sign in to FB from myapp at all.

I think the chance of this issue to cause headache is rather slim.  Most likely, users will choose one app over the other and wouldn’t have both app installed.  And if they do, most likely, they’d sign in to FB from first one before they install the second one, which would not trigger this strange bug.  So, for now, I’m going to table this as known issue but not worry too much about it.

Naomi

Hi Naomi,

Interesting, it sounds like what you’re experiencing is similar but not exactly the same as what I’m experiencing.

Either way, I agree, it’s not likely to be a significant issue because, like you said, most users would only have one version installed.  (It’s more of an issue during development and beta testing.)

In case anyone is interested, this Facebook link shows more info on this: https://developers.facebook.com/docs/ios/troubleshooting

An here is some info about the order in which apps are called:

“The order in which you list the suffixes determines the order that the Facebook app searches for the installed app when linking to your app. For example, if you list two URL Scheme Suffix entries, ‘‘freeapp’’ (for your free app) and ‘‘paidapp’’ (for your paid app), the Facebook app will look for the free app first, followed by the paid app.”

I want to confirm that doing this:

  1.         CFBundleURLSchemes =
  2.        {
  3.             “fbxxxxxxxxxxxxxxxmyapppro”,
  4.             “fbxxxxxxxxxxxxxxx”,
  5.        },

DOES work on the device, BUT it does not work on the iOS simulator.

 

For it to works it needs a newer version of the Facebook App to be installed in the device, and the iOS simulator does not have the Facebook App installed.

 

If you don’t have the Facebook app installed and you are not logged in to Facebook in iOS7 preferences, it will fail. But as soon as you login to Facebook in iOS7 preferences or you login to the Facebook app, it will redirect correctly.

 

Keep in mind that I used a different suffix for each different version of my app, and I did NOT add the suffix to the FacebookAppID value on the build settings, and I also did NOT add the suffix to the init code in my app.

Jorge

In case anyone is interested, this Facebook link shows more info on this: https://developers.facebook.com/docs/ios/troubleshooting

An here is some info about the order in which apps are called:

“The order in which you list the suffixes determines the order that the Facebook app searches for the installed app when linking to your app. For example, if you list two URL Scheme Suffix entries, ‘‘freeapp’’ (for your free app) and ‘‘paidapp’’ (for your paid app), the Facebook app will look for the free app first, followed by the paid app.”

I want to confirm that doing this:

  1.         CFBundleURLSchemes =
  2.        {
  3.             “fbxxxxxxxxxxxxxxxmyapppro”,
  4.             “fbxxxxxxxxxxxxxxx”,
  5.        },

DOES work on the device, BUT it does not work on the iOS simulator.

 

For it to works it needs a newer version of the Facebook App to be installed in the device, and the iOS simulator does not have the Facebook App installed.

 

If you don’t have the Facebook app installed and you are not logged in to Facebook in iOS7 preferences, it will fail. But as soon as you login to Facebook in iOS7 preferences or you login to the Facebook app, it will redirect correctly.

 

Keep in mind that I used a different suffix for each different version of my app, and I did NOT add the suffix to the FacebookAppID value on the build settings, and I also did NOT add the suffix to the init code in my app.

Jorge