[Closed] URL Scheme Suffix -- Sharing a single FB app ID across multiple apps

I’d like to have my free and paid versions of iOS app to share a single FB app ID, but what I’ve done so far seems not to be working.  I must be missing something, but I don’t know what that might be.

Here’s what I have for build.settings :

[lua]

settings = {

    iphone = {

        plist {

            UIApplicationExitsOnSuspend = false,

            FacebookAppID = “123456789012345”,

            CFBundleURLTypes = {

                {

                        CFBundleURLSchemes =

                        {

                            “fb123456789012345”,

                            “fb123456789012345myapppro”,

                        },

                },

            },

        },

    },

}

[/lua]

On FB dev site, under Native iOS App section, I have:

Bundle ID:  com.mycompany.myapp, com.mycompany.myapppro

iPhone App Store ID:  123456789  <-- this is the the App Store ID for myapp

iPad App Store ID:  123456789  <-- this is the the App Store ID for myapp

Facebook Login:  Enabled

Deep Linking:  Enabled

URL Scheme Suffix:  myapp, myapppro

What else am I suppose to do to ensure both myapp and myapppro can work with single FB app ID?

Currently, if my device has both myapp and myapppro installed, upon logging in to FB from the app, it always goes back to one of them.  Meaning, if I launch myapp, sign in to FB, all is well.  Then I close myapp, and then launch myapppro, sign in to FB… then it forces myapp to open and myapppro is unable to sign in to FB.  What’s worse, if I delete myapp, launch myapppro and sign in to FB, it simply fails to sign in to FB.

I must be missing something or doing something wrong.  What do I need to do to fix this?

Naomi

Edit 1:  I found that URL Scheme Suffix used to work with Corona daily 1105.  It no longer works with Corona daily 1193.  Please see more details in the reply posts below.

Edit 2 :  OMG, as I worked on putting together a test project to demonstrate this whole problem, I’m suddenly seeing this thing working just the same between 1105 builds and 1193 builds.  I’m now totally confused.

No one?  I’m sure it can be done, and I’d be surprised if none of the Corona Devs have done this successfully:

https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/

I’m sure I’m missing something.  What could it be that I’m not doing right – unless Corona implementation of FB doesn’t allow it (which I doubt is the case, but I just don’t know.)

I’d so appreciate hearing any suggestions, pointers, hints, etc.

Naomi

Hi Naomi.   For what you are doing you probably only want one URL scheme for your paid app and a separate one for the free app.  In other words the build settings for paid should only have one listed.  The build.settings for the free should only have one.  If they have different suffixes that match what you have in your facebook portal, then it should work.

There will be times one app might want to respond to different URL schemes.  So your app might need to respond to Facebook, Twitter, etc.  In this case, FB requires a specific URL Scheme, some other service may want their specific scheme. 

So have separate build settings and put in the right suffix for the one you’re currently building.

Ah, okay, thank you, Rob.  I thought I tried it, but maybe I didn’t do it the way I thought I did.  (Too many device builds created, installed, deleted, re-created, reinstalled, etc., and somewhere along the way, things might’ve gotten mixed up.)  Let me give it a go again and see if it fixes it.

Thanks again.  Really appreciate your help.

Naomi

So, Rob, I tried it, and it still does not behave for me.  Here’s what I’ve done:

  1.  Generated myapp.app with “fb123456789012345” as its CFBundleURLSchemes, (commenting out the other one.)  (Note:  replace 123456789012345 with proper appID)

  2.  Generated myapppro.app with “fb123456789012345myapppro” as its CFBundleURLSchemes, (commenting out the other one.)

  3.  Deleted previously installed myapp.app and myapppro.app from all iOS test devices

  4.  Installed newly generated myapp.app and myapppro.app (each uses its own & single CFBundleURLSchemes as noted above.)

  5.  Launched myapp.app, signed in to FB, which works like it should.

  6.  Launched myapppro.app, signed in to FB, which ends up launching myapp.app after successful sign in to FB.  Hitting home button and tapping on myapppro.app icon opens myapppro with an alert, stating login to FB failed.

  7.  Deleted both myapp.app and myapppro.app from all iOS test devices.

  8.  Reinstalled myapp.app and myapppro.app that I generated at step #1 and #2 to iOS devices

  9.  Launched myapppro.app, signed in to FB, which ends up launching myapp.app after successful sign in to FB.  Hitting home button and tapping on myapppro.app icon opens myapppro with an alert, stating login to FB failed.

After FB sign in, it simply wants to return to myapp.app, not myapppro.app.  If I uninstall myapp.app, and try myapppro.app, it simply fails:

i)  After deleting myapp.app, I launch myapppro.app and try logging in to FB.

ii) FB login automatically opens native FB app, and it remains blank.

iii)  I close native FB app, delete native FB app, and then try FB login again via myapppro.app, which opens up Safari based FB login screen.

iv)  I enter FB email and password to sign in, but it eventually leads me to an alert that says “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

v)  I tap on home button and return to myapppro, which also tells me that FB login failed.

What else could I be doing wrong?  I really appreciate all your help regarding this.

Naomi

Edit 1:  BTW, just to make it 200% sure, I double and tripple checked the distribution certificates I used for each app (meaning, each uses separate distribution certificate.)  So I know for sure that’s not where it fails.

Edit 2:  I went ahead and wiped one of my iOS devices (settings > general > reset > erase all content and settings), and then installed myapppro only, and tried again – but with the same result as the steps i through v above.  That is, I enter FB email & password, which works fine and brings up “you have already authorized the app” screen, and I tap on OK, which then ends up with “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

You’re getting into some areas where I don’t have a lot of experience, but can you one other thing.  Make sure both apps are using a suffix.  Here are what seems like a couple of relevant posts on the matter:

http://stackoverflow.com/questions/7368515/how-to-have-a-paid-and-free-version-of-ios-app-share-fb-app-id

https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/ (make sure to read the last bits on this)

Thank you, Rob.  I don’t know what is so wrong with my app, but I’m still unable to get it to work.

I think my app is set up correctly on FB dev site (see my initial post.)  It’s been set up that way for quite a while now, so I don’t think I need to wait for things to propagate – unless I need to add two app store ID, instead of one.

I now changed CFBundleURLSchemes to:

“fb123456789012345myapp” <-- for myapp

“fb123456789012345myapppro” <-- for myapppro

I generated myapp and myapppro again (each having its own designated CFBundleURLSchemes, and using proper distribution certificate for each.)

Now, both myapp and myapppro gets “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

It just does not accept the suffix.  If I don’t include the suffix, it goes back to (or launches) myapp upon sign in, that is, only if the app is installed, and if the app isn’t installed, it simply fails.

So… I decided to test this problem with my already released myapp and myapppro versions.  They were built with Corona daily build 1105 – and the result is totally different from what I’m seeing now with the updated version being built with Corona daily 1193.

With the already released versions, here’s what happens:

  1.  Install myapp and myapppro (directly downloaded from Apple App Store)

  2.  Launch myapppro, sign in to FB – which completes successfully, returning back to myapppro as expected.

  3.  Launch myapp, sign in to FB – which actually launches myapppro, which is not an expected behavior.

  4.  Delete myapppro, launch myapp, sign in to FB – which completes successfully, returning back to myapp as expected.

  5.  Install myapppro (downloaded from Apple App Store again)

  6.  While myapp is still installed, launch myapppro, sign in to FB – which completes successfully this time, returning back to myapppro as expected.

  7.  Launch myapp (while myapppro is still installed and active), sign in to FB – which completes successfully this time, returning back to myapp as expected.

  8.  Now, toggling back and forth between the two apps does not affect the FB sign in process and it always return back to the correct app.

Sigh.  I thought these two apps were able to share a single FB App ID when I released them – and I’d have to say they are working fine.  I only thought they were broken when testing the latest release candidates.  At this point, it seems more likely that latest FB SDK update might have caused something to break?  The latest versions of myapp and myapppro are not able to share single FB App ID like they used to.

What do I do now?

Naomi

I’m going to ask you to try one last thing.  Just in case there is some weird substring matching going on.  Make your free suffix:  myappfree instead of myapp.  I wonder if it’s doing a “does the string start with myapp” type logic.  Everything I saw had unique names.

If not, please submit a bug report on it.  It’s probably something Facebook broke along the way.  The other thing you can try too is look at the facebook.publishinstall docs in the Daily Build documentation.  You will see the URL scheme’s are structured differently.  One of the examples showed a screen shot of a plist setting in XCode and it was structured like the way publishinstall is, not the way we normally say to do it.  Maybe this is Facebook’s broken changes?

Thank you, Rob.  I really appreciate your help.

I changed myapp to myappfree (and updated FB dev site to show URL Scheme Suffix:  myappfree, myapppro), waited half an hour, and then tried again – and both myapp and myapppro still won’t sign in to FB (they both give me “Cannot Open Page.  Safari cannot open the page because the address is invalid.”)  FB sign in process definitely does not like the suffix there.

I looked at how build.settings work with facebook.publishinstall, and it does look a bit more like what I see on https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/ page.  So, I’ll give it a try – but does this mean I should remove this whole CFBundleURLTypes block:  

CFBundleURLTypes = { { CFBundleURLSchemes = { “fb123456789012345myapp”, }, }, }, – for myapp

CFBundleURLTypes = { { CFBundleURLSchemes = { “fb123456789012345myapppro”, }, }, }, – for myapppro

And replace it with [“URL types”] block?

[“URL types”] = { item = { [“URL Schemes”] = { [“Item 0”] = “fb123456789012345myapp” }, }, }, – for myapp

[“URL types”] = { item = { [“URL Schemes”] = { [“Item 0”] = “fb123456789012345myapppro” }, }, }, – for myapppro

Or do I keep both CFBundleURLTypes block and [“URL types”] block in build.settings?  (It feels like I probably should remove CFBundleURLTypes block, but I thought I should confirm.)  I should just give both a try, I suppose…

Naomi

 

So, I tried both – that is, I tried adding [“URL types”] block only, as well as adding both CFBundleURLTypes block and [“URL types”] block – and tested myapppro, and they both failed:

  1.  When I add [“URL types”] block only, it behaves the same as having CFBundleURLTypes block only – that is, I get “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

  2.  When I have both CFBundleURLTypes block and [“URL types”] block, it ends up with all of the display.newText objects becoming invisible on device (even though they look fine on simulator.)  Very strange, and definitely not a solution we could consider.  Despite not being able to see any text on screen, I still tried logging in to FB via the app, and it didn’t even bring up FB sign in screen or FB permission screen.  It simply resulted in failed FB login.

So, adding [“URL types”] block was not a solution.  At this point, I’d have to say this is a bug.

Naomi

Thanks Naomi.  I guess at this point, a bug report is in order.  Please include a link to this thread in the submission.  I don’t know if its an “us” or “them”, but we will try to get to the bottom of it.

Rob

Hi Rob, you know, I just put together a FBTest project file, and compiled PRO and FREE versions using Corona 1105, and they both behave as expected.  I then built PRO and FREE versions using Corona 1193, and then I’m seeing them both behaving just the same as the ones built with 1105.  In other words, it’s suddenly working correctly.  

I am now totally confused.  The build.settings I’m using for the FBTest project file is the same as the one I posted up top, meaning, I include both “fb123456789012345” and “fb123456789012345myapppro”.

I don’t get this at all.

And fortunately, I did keep the release candidates of myapp and myapppro that I generated back on August 20th, and I installed them both, and tested them again – and this time, they are both working as expected.

What is going on?  What went on?  Why are they working now, when they refused to work yesterday?  I really don’t get this.

But I suppose I can close this thread now, because, for whatever reason, the problem was only temporary.

Anyhow, thanks again, Rob, for being there for me and taking the time to work through this with me.

Naomi

Facebook  can be fickle at times.  Glad it’s working for you.

No one?  I’m sure it can be done, and I’d be surprised if none of the Corona Devs have done this successfully:

https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/

I’m sure I’m missing something.  What could it be that I’m not doing right – unless Corona implementation of FB doesn’t allow it (which I doubt is the case, but I just don’t know.)

I’d so appreciate hearing any suggestions, pointers, hints, etc.

Naomi

Hi Naomi.   For what you are doing you probably only want one URL scheme for your paid app and a separate one for the free app.  In other words the build settings for paid should only have one listed.  The build.settings for the free should only have one.  If they have different suffixes that match what you have in your facebook portal, then it should work.

There will be times one app might want to respond to different URL schemes.  So your app might need to respond to Facebook, Twitter, etc.  In this case, FB requires a specific URL Scheme, some other service may want their specific scheme. 

So have separate build settings and put in the right suffix for the one you’re currently building.

Ah, okay, thank you, Rob.  I thought I tried it, but maybe I didn’t do it the way I thought I did.  (Too many device builds created, installed, deleted, re-created, reinstalled, etc., and somewhere along the way, things might’ve gotten mixed up.)  Let me give it a go again and see if it fixes it.

Thanks again.  Really appreciate your help.

Naomi

So, Rob, I tried it, and it still does not behave for me.  Here’s what I’ve done:

  1.  Generated myapp.app with “fb123456789012345” as its CFBundleURLSchemes, (commenting out the other one.)  (Note:  replace 123456789012345 with proper appID)

  2.  Generated myapppro.app with “fb123456789012345myapppro” as its CFBundleURLSchemes, (commenting out the other one.)

  3.  Deleted previously installed myapp.app and myapppro.app from all iOS test devices

  4.  Installed newly generated myapp.app and myapppro.app (each uses its own & single CFBundleURLSchemes as noted above.)

  5.  Launched myapp.app, signed in to FB, which works like it should.

  6.  Launched myapppro.app, signed in to FB, which ends up launching myapp.app after successful sign in to FB.  Hitting home button and tapping on myapppro.app icon opens myapppro with an alert, stating login to FB failed.

  7.  Deleted both myapp.app and myapppro.app from all iOS test devices.

  8.  Reinstalled myapp.app and myapppro.app that I generated at step #1 and #2 to iOS devices

  9.  Launched myapppro.app, signed in to FB, which ends up launching myapp.app after successful sign in to FB.  Hitting home button and tapping on myapppro.app icon opens myapppro with an alert, stating login to FB failed.

After FB sign in, it simply wants to return to myapp.app, not myapppro.app.  If I uninstall myapp.app, and try myapppro.app, it simply fails:

i)  After deleting myapp.app, I launch myapppro.app and try logging in to FB.

ii) FB login automatically opens native FB app, and it remains blank.

iii)  I close native FB app, delete native FB app, and then try FB login again via myapppro.app, which opens up Safari based FB login screen.

iv)  I enter FB email and password to sign in, but it eventually leads me to an alert that says “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

v)  I tap on home button and return to myapppro, which also tells me that FB login failed.

What else could I be doing wrong?  I really appreciate all your help regarding this.

Naomi

Edit 1:  BTW, just to make it 200% sure, I double and tripple checked the distribution certificates I used for each app (meaning, each uses separate distribution certificate.)  So I know for sure that’s not where it fails.

Edit 2:  I went ahead and wiped one of my iOS devices (settings > general > reset > erase all content and settings), and then installed myapppro only, and tried again – but with the same result as the steps i through v above.  That is, I enter FB email & password, which works fine and brings up “you have already authorized the app” screen, and I tap on OK, which then ends up with “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

You’re getting into some areas where I don’t have a lot of experience, but can you one other thing.  Make sure both apps are using a suffix.  Here are what seems like a couple of relevant posts on the matter:

http://stackoverflow.com/questions/7368515/how-to-have-a-paid-and-free-version-of-ios-app-share-fb-app-id

https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/ (make sure to read the last bits on this)

Thank you, Rob.  I don’t know what is so wrong with my app, but I’m still unable to get it to work.

I think my app is set up correctly on FB dev site (see my initial post.)  It’s been set up that way for quite a while now, so I don’t think I need to wait for things to propagate – unless I need to add two app store ID, instead of one.

I now changed CFBundleURLSchemes to:

“fb123456789012345myapp” <-- for myapp

“fb123456789012345myapppro” <-- for myapppro

I generated myapp and myapppro again (each having its own designated CFBundleURLSchemes, and using proper distribution certificate for each.)

Now, both myapp and myapppro gets “Cannot Open Page.  Safari cannot open the page because the address is invalid.”

It just does not accept the suffix.  If I don’t include the suffix, it goes back to (or launches) myapp upon sign in, that is, only if the app is installed, and if the app isn’t installed, it simply fails.