Multiple Apps using the same Facebook app

Hi there !

I’d like to know if a several apps can use the same facebook app.

I tried but, it seems that url scheme can be confusing due to corona restriction :

See here : http://blog.anscamobile.com/2011/12/uploading-photos-to-facebook-in-corona/
[lua] CFBundleURLSchemes =
{
“fbXXXXXXXXXXXXXX”,
}
[/lua]

Using the same URLscheme is impossible for 2 apps on the same device.

Is there a walkthrough to this ? [import]uid: 3638 topic_id: 23006 reply_id: 323006[/import]

I thought that two apps could use the same URL Schema and the user would be prompted for which app to use if there was a collision.

[import]uid: 19626 topic_id: 23006 reply_id: 91943[/import]

Please, let’s bump this up in priority!

I generate multiple apps from one code set, i.e. ebooks. I don’t want a new Facebook app for each one, just to post pictures to Facebook!

Facebook has a way to share FB apps across multiple mobile apps, called a urlSchemeSuffix.

Please, we need to know where this can be implemented, and an example of how to implement this in Corona! Urgent! [import]uid: 37366 topic_id: 23006 reply_id: 101065[/import]

Do you mean this?

http://blog.anscamobile.com/2011/12/using-app-url-schemes-in-ios/

and this?

http://blog.anscamobile.com/2012/01/implementing-facebook-single-sign-on/

or is there a piece still missing? [import]uid: 19626 topic_id: 23006 reply_id: 101082[/import]

Yes, there is still a piece missing. Facebook allows multiple mobile apps to share a single Facebook app. What’s missing is an example of using the “URL Scheme Suffix” to allow a single FB app to service multiple mobile apps.

I have tried creating a CFBundleURLSchemes entry in the correct form, e.g.
fbxxxxxxxMyAppSuffix
but FB on the iPad did not return to my app.

So, yes, some help would be great here! I have apps for clients waiting!

See: https://developers.facebook.com/docs/mobile/ios/build/#multiples

[import]uid: 37366 topic_id: 23006 reply_id: 101357[/import]

I have the same problem… please any help. I tried with the suffix, i come back to the correct app but the login failed! [import]uid: 145329 topic_id: 23006 reply_id: 112345[/import]

Yeah, this is a real problem
[import]uid: 95944 topic_id: 23006 reply_id: 118337[/import]

+1 [import]uid: 1989 topic_id: 23006 reply_id: 118342[/import]

Is this working now? [import]uid: 105206 topic_id: 23006 reply_id: 119516[/import]

Is this working now? [import]uid: 105206 topic_id: 23006 reply_id: 119516[/import]

Hi everyone,

Rob, not sure if you’re still following this thread, but I wanted to come back on this issue with a more detailed explanation and two possible ways to address it (either of which might be fairly easy to implement).

The overall issue is having multiple Corona apps for iOS use the same Facebook app ID and URL schema. Facebook provides a mechanism to do this, but it doesn’t currently seem possible to utilize it in Corona (except, perhaps, with Enterprise). Of course, if anyone else has figured out how to do it, I’d be interested to hear!

First off, why would anyone want to have multiple apps use the same Facebook app ID and URL schema? Two reasons. The most common reason is to have a paid and free version of your app be linked to the same Facebook app. Second, it can be helpful to have development/beta versions of your app (which might use a different iOS bundle ID) to be linked to the same Facebook app for more accurate testing of the Facebook integration.

Of course, it’s unlikely most users will install a paid and free version of an app at the same time, so most real users will only have one version of the app running on their device. Still, for facebook analytics about your app, it’s better to have the versions under one Facebook app ID than separate.

To allow multiple apps to share the same Facebook app ID, Facebook has a concept called the URL Scheme suffix (http://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/). Basically, when you login to facebook, you pass not only the URL Scheme but also a suffix identifying which version of your app it is.

I think there are two ways to get this to work in Corona.

First, I think the [lua]facebook.login()[/lua] API could be supplemented with an option field for the suffix. The native Objective C code supporting the API would be slightly modified to pass the suffix to Facebook, per Step 1 in the link above. (Using the existing [lua]facebook.login()[/lua] API, simply appending the suffix to the Facebook app ID doesn’t work, since Facebook doesn’t know to parse the suffix out.)

Second, Corona could update to the Facebook 3.2 SDK. According to this Facebook bug report (https://developers.facebook.com/bugs/258147420977823/), in the 3.2 SDK, it’s possible to specify the suffix using a plist key of FacebookUrlSchemeSuffix. Of course, upgrading the Facebook SDK again might entail a whole host of other work, so I could see that not being as palatable.

Thanks!

  • Andrew [import]uid: 109711 topic_id: 23006 reply_id: 145780[/import]

Hmm, it turns out that I can get it to work after all, if in build.settings I include *both* my app ID without and with the suffix I want, like this:
[blockcode]
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fbAPP_ID”,
“fbAPP_IDSUFFIX”,
}
}
}
[/blockcode]

Cool!

  • Andrew [import]uid: 109711 topic_id: 23006 reply_id: 145808[/import]

Hi everyone,

Rob, not sure if you’re still following this thread, but I wanted to come back on this issue with a more detailed explanation and two possible ways to address it (either of which might be fairly easy to implement).

The overall issue is having multiple Corona apps for iOS use the same Facebook app ID and URL schema. Facebook provides a mechanism to do this, but it doesn’t currently seem possible to utilize it in Corona (except, perhaps, with Enterprise). Of course, if anyone else has figured out how to do it, I’d be interested to hear!

First off, why would anyone want to have multiple apps use the same Facebook app ID and URL schema? Two reasons. The most common reason is to have a paid and free version of your app be linked to the same Facebook app. Second, it can be helpful to have development/beta versions of your app (which might use a different iOS bundle ID) to be linked to the same Facebook app for more accurate testing of the Facebook integration.

Of course, it’s unlikely most users will install a paid and free version of an app at the same time, so most real users will only have one version of the app running on their device. Still, for facebook analytics about your app, it’s better to have the versions under one Facebook app ID than separate.

To allow multiple apps to share the same Facebook app ID, Facebook has a concept called the URL Scheme suffix (http://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/). Basically, when you login to facebook, you pass not only the URL Scheme but also a suffix identifying which version of your app it is.

I think there are two ways to get this to work in Corona.

First, I think the [lua]facebook.login()[/lua] API could be supplemented with an option field for the suffix. The native Objective C code supporting the API would be slightly modified to pass the suffix to Facebook, per Step 1 in the link above. (Using the existing [lua]facebook.login()[/lua] API, simply appending the suffix to the Facebook app ID doesn’t work, since Facebook doesn’t know to parse the suffix out.)

Second, Corona could update to the Facebook 3.2 SDK. According to this Facebook bug report (https://developers.facebook.com/bugs/258147420977823/), in the 3.2 SDK, it’s possible to specify the suffix using a plist key of FacebookUrlSchemeSuffix. Of course, upgrading the Facebook SDK again might entail a whole host of other work, so I could see that not being as palatable.

Thanks!

  • Andrew [import]uid: 109711 topic_id: 23006 reply_id: 145780[/import]

Hmm, it turns out that I can get it to work after all, if in build.settings I include *both* my app ID without and with the suffix I want, like this:
[blockcode]
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fbAPP_ID”,
“fbAPP_IDSUFFIX”,
}
}
}
[/blockcode]

Cool!

  • Andrew [import]uid: 109711 topic_id: 23006 reply_id: 145808[/import]

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.