Per-bundleid Facebook iOS url scheme - ios

I have encountered an unfortunate design issue with the Facebook iOS SDK. The problem is our company produces many branded apps from the same prototype codebase (think restaurant ordering) that all need to interact with the same Facebook app.
The problem is that if a user has multiple brands installed on their phone, the url schemes conflict and when authenticating from one app, the user may be returned to the wrong app!
I looked into Facebook's url scheme suffixes, but the documentation says multiple suffixes are searched in order (!), not relative to the corresponding bundle id. This is horrible. If it simply associated a suffix with a particular bundle id, our problem would go away, but as it is documented, it will place precedence on certain brands over other brands, which is no better than the default behavior.
Is there any way to associate a url scheme suffix with a specific bundle id?

You can explicitly specify the suffix for each app by setting FacebookUrlSchemeSuffix in the application's plist. When this happens, for the purposes of login and share dialog, the Facebook app will know the right suffix to use.
The only time it searches down the list of suffixes is for deep linking, which you may or may not use.
In any case, you might want to have different app IDs anyways as #WizKid recommends since you'll be able to get analytics for each app, and it also becomes easier to maintain.

Related

Is there a way to present users an option for which app to open when multiple apps use the same universal link? [duplicate]

I have two apps under same firebase project, those share the same deep link
How are links handled by the OS if more than one App can use the same universal link? How do I choose the app that is going to be opened to handle certain pages?
for example, both apps share same universal link https://xxx.app.goo.gl
how will it be identified to open user or manager app?
According to Apple, this is dependent on the ordering of your AASA file.
The order of the dictionaries in the array determines the order the system follows when looking for a match, so you can specify an app to handle a particular part of your website.
The app that is listed first in the AASA file will take precedence. You can check that by looking at the AASA endpoint: https://xxx.app.goo.gl/apple-app-site-association
You can also specify certain paths to be handled separately, but if both apps share the same paths then the one listed first in the AASA will open.

How to open my iOS App with custom URL scheme in Swift 3?

I need to open my particular UIViewController when the following link is clicked on the Safari browser:
http://my.sampledomain.com/en/customer/account/resetpassword/?id=24&token=8fbf662617d14c10f4a11f716c1b2285
When this link is clicked on the browser, I need to open my application on a particular screen and retrieve the data from this url. For example:
id = 24
token = 8fbf662617d14c10f4a11f716c1b2285
...and pass it to that particular UIViewController.
How can i do that?
What you are describing is called Deep Linking. It's a very common app feature to implement — most apps have it — and conceptually, it seems like an easy thing to build. However, it's complicated to get right, and there are a lot of edge cases.
You basically need to accomplish two things:
If the app is installed: open the app and route users to the correct content inside it.
If the app is NOT installed: forward users to the App Store so they can download it. Ideally, also route users to the correct content inside the app after downloading (this is known as 'deferred deep linking').
While not required, you'll also probably want to track all of this activity so you can see what is working.
If the app is installed
Your existing custom URI scheme fits into this category. However, Apple has decided that custom URI schemes are not a good technology, and deprecated them with iOS 9 in favor of Universal Links.
Apple is right about this. Custom URI schemes have a number of problems, but these are the biggest:
There is no fallback if the app isn't installed. In fact, you get an error.
They often aren't recognized as links the user can click.
To work around these, it used to be possible to use a regular http:// link, and then insert a redirect on the destination page to forward the user to your custom URI scheme, thereby opening the app. If that redirect failed, you could then redirect users to the App Store instead, seamlessly. This is the part Apple broke in iOS 9 to drive adoption of Universal Links.
Universal Links are a better user experience, because they are http:// links by default and avoid nasty errors. However, they are hard to set up and still don't work everywhere.
To ensure your users end up inside the app when they have it installed, you need to support both Universal Links and a custom URI scheme, and even then there are a lot of edge cases like Facebook and Twitter which require special handling.
If the app is NOT installed
In this case, the user will end up on your http:// fallback URL. At this point, you have two options:
Immediately forward the user directly to the App Store.
Send the user to your mobile website (and then use something like a smart banner to give them the option of going to the App Store).
Most large brands prefer the second option. Smaller apps often go with the first approach, especially if they don't have a website.
To forward the user to the App Store, you can use a Javascript redirect like this:
<script type="text/javascript">
window.onload = function() {
window.location = "https://itunes.apple.com/app/id1121012049";
};
</script>
Until recently, it was possible to use a HTTP redirect for better speed, but Apple changed some behavior in Safari with iOS 10.3, so this no longer works as well.
Deferred deep linking
Unfortunately there's no native way to accomplish this last piece on either iOS or Android. To make this work, you need a remote server to close the loop. You can build this yourself, but you really shouldn't for a lot of reasons, not the least of which being you have more important things to do.
Bottom line
Deep linking is very complicated. Most apps today don't attempt to set it up by building an in-house system. Free hosted deep link services like Branch.io (full disclosure: they're so awesome I work with them) and Firebase Dynamic Links can handle all of this for you, and ensure you are always up to date with the latest standards and edge cases.
See here for a video overview an employee at Branch made of everything you need to know about this.

Program UIButton to open Facebook app to specific page, and same for twitter and instagram

I am building an app that when you click a button labeled "Facebook", "Twitter", or "Instagram", it will open the respective app and take you to the specific page I set. I've been searching non-stop for answers for the last week, if anyone can help I would greatly appreciate it!
I have been all over StackOverflow and other forums and videos and cannot find the answer to this question. Either the solutions I find are outdated and do not work anymore or are not exactly what I want.
Please note: typically a question like this is not going to get very useful answers on SO. In the future, try to be more specific and show a little work. However, I appreciate how it can be difficult to search for a solution when you don't know the correct terminology. The term you are looking for is "URL scheme"
Each app has its own URL schemes for opening specific pages and/or websites. You will need to check their documentation and/or search online to see if you can find the URL schemes you need. There was an unofficial website listing a lot of these, but it is no longer maintained.
For example, to open a specific Facebook profile page (could be a person, or a company, etc) use:fb://profile/<page id>" replacing the with the Facebook ID corresponding to the page. This is a numeric value, you can find it sometimes in the URL, but http://findmyfbid.com/ is a useful resource for this.
Then you can simply trigger open on the shared UIApplication instance to open the URL. But keep in mind the user may not have Facebook installed, so you should use canOpenURL to check if the URL scheme you are trying to use is supported, and if not you can just open the URL in a browser.
However, some apps may have implemented the new features for Universal linking, so the device may automatically open the appropriate page if you just provide a standard URL, like https://facebook.com/<page_id>. I suggest playing around with it.
Note, for each URL scheme you want to be able to check canOpenURL with, you will need to add it to your app's plist.
Since I already have Instagram and Twitter handy here are their basic schemes for opening a user's page:
instagram://user?username=<username>
twitter://user?screen_name=<username>
Note: there are other URL schemes that these apps support (e.g. you could link to a location page, or a specific tag, on Instagram) so you should check their documentation for more information on URL schemes.

How to create vanity url for apple appStore?

Recently news are coming out that one can create vanity url for Apple Appstore.
But I cant find any options additionally added in itunes connect to do it.
any help is appreciated :)
It seems we dont have to do anything ...
just we have to add the company name or app name at the end of http://appstore.com/
It seems since all the app names and company names are already unique, apple does the all background job of rerouting the appstore-link to the actual itunes-link..
iOS: http://appstore.com/<.companyname.> for example, http://appstore.com/ikural
Mac: http://appstore.com/mac/<.companyname.> for example, http://appstore.com/mac/popcap
apple has provided this Q&A page
You don't create it. It is based on your company or application name. It is not very robust (two applications with the same name can have the same URL). See Apple's Technical Q&A.
In particular, the last paragraph reads:
These App Store Short Links are provided as a convenience and are not
guaranteed to link to a particular app or company. Be sure to test
your URLs before using them in any marketing or other public
materials. If there are naming conflicts, continue using the standard
itunes.apple.com URLs, which contain a unique numerical identifier
within the URL.

Can I have more than one custom URL Scheme for authentication with the Facebook iOS SDK

upon reading the docs it states:
Adding your Facebook App ID
Finally, you need to place the Facebook app ID in two places in your
application's main .plist file. Create a key called FacebookAppID with
a string value, and add the app ID there:
Also, create an array key called URL types with a single array
sub-item called URL Schemes. Give this a single item with your app ID
prefixed with fb:
My question is the following. We have 2 development environments with our app, and I would like to avoid creating another build target, when there are basically a couple of environment variables that need to change. The docs here above status 'a single item', but it would be great if I could put in 2 items, i.e. fb8234923847293 and fb0238343466 (not the real ids)
I don't think this will work.
Is there anyway I can declare multiple URL schemes, so that if the facebook app wants to launch my app after authenticating, my app will respond to requests from either of those 2 development facebook apps that we have?
So, my question was based on something I must have remembered incorrectly, because I thought the app doesn't deal well with multiple Facebook App URLs. It does.
For completeness, I'll answer the question. In the FB docs where it tells you to create an item in the URL Schemes array, you can just keep adding more schemes based on the various FB App IDs in that array, and the app will respond to any one of those.
Simple.

Resources