iOS Universal link not working in react-native iOS - ios

Hi I know this question being asked before still I cannot figure out what am doing wrong.
Added apple-app-site-association file in our server under https://ourserver.com/.well-known/apple-app-site-association
The file content is as follows
`
{
"applinks":{
"apps":[],
"details":[
{
"appID":"<teamId>.<bundleId>",
"paths":[ "*", "/" ]
}
]
}
}
`
3. Associated Domain is added as capability with
applinks:servername.com
applinks:dev.servername.com
Added code in AppDeletegate.m
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
EDIT 1
Noticed something i tried universal linking in iOS versions 12.4.2 iPhone and it redirected correctly. Where as in iOS version 14 it redirected to our web page. So I updated my apple-app-site-association file as follows
{
"applinks": {
"details": [
{
"appIDs": [
"teamid.bundleid"
],
"components": [
{
"/": "/*",
"comment": "Matches any URL whose path starts with URL_PATH and instructs the system not to open it as a universal link"
},
{
"/": "*",
"comment": "Matches any URL whose path starts with URL_PATH and instructs the system not to open it as a universal link"
}
],
"paths": [
"*",
"/"
]
}
]
}
}
oru web url is validated in this link
All the testing is done in real devices.
EDIT 2
All below is tested in Simulator - iPhone 11 Pro iOS 14.4
Tested the same in a simulator with developer mode
applinks:servername.com?mode=developer
applinks:dev.servername.com?mode=developer
it opened correctly in SIMUALTOR
then i misspelled our server name and clicked from iMessages it redirected to Safari in SIMULATOR -
I tried again with correct server name after clearing Safari history and cache - STILL IT REDIRECTES TO BROWSER NOT APP
EDIT 3
On Simulator
Went through this link and saw about Smart App banner since i couldn't find anything like that. After searching found this SO Post and tried Settings - Safari - Advanced - Website Data - In the page showed my domain name - Clear Website Data.
Tried again on Simulator and app opened correctly
On iPhone with release adhoc build
On Real Device did the same Settings - Safari - Advanced - Website Data - In the page showed my domain name - Clear Website Data but it didn't work. Still it opens the browser in app
EDIT 4
the AASA file in EDIT 2 make the redirection fail in iOS version 12.4.2. Hence updated it like this
{
"applinks":{
"apps":[
],
"details":[
{
"appID":"teamid.bundleid",
"paths":[
"*",
"/"
],
"appIDs":[
"teamed.bundleid"
],
"components":[
{
"/":"/*"
},
{
"/":"*"
}
]
}
]
}
}
After updating to this redirects to app in version 12.4.2 but fails in 14 and above versions. Modified AASA file after going through this link
Any Help is Appreciated
Thanks in advance

I was having the same issue and saw above #suja haven't resolved it yet so I thought to post the answer here.
First we need to double-check our <teamID>.<bundleID> pattern. Because if our association file doesn't recognize this if it's wrong (even though if we got all other steps correctly).
I found this useful official link and saw this video carefully. Also, the video slides can be seen here in PDF
Actually, they've updated the contents regarding association file, like
appID: string_value key now turns into appIDs: array_of_strings
the paths key has now been replaced by components
If you want to test in Simulator during development, then you should use a query parameter mode=developer at the end of the matching URL in the Association Domains capability in XCode.
You cannot use http:// (like if you are launching your website locally using localhost:PORT then you should use some external service to make your localhost available as a public link). In my case, I did use ngrok to mock my localhost as https://, also don't forget to allow that ngrok URL in CORS policy, if web services (APIs) are being called from your web pages.
apple-app-site-association must be in a public folder of your website under subdirectory .well-known
Now combine all steps. I was having the same issue since yesterday then I found the above links from the official Apple site to get this done and to understand how exactly Universal link works.
Most importantly, if you are testing on Simulator, then please make sure that from your Apple developer Account that your development appID.bundleID should be exact in the association file.
below is my association file as an example
{
"applinks": {
"details": [
{
"appIDs": [
"YOUR_PRODUCTION_TEAM_ID.com.yourapp_bundleID",
"YOUR_DEV_TEAM_ID.com.yourapp_bundleID.dev"
],
"components": [
{
"/": "*",
"comment": "Matches any URLs"
}
]
}
]
}
}
And for production, don't forget to add the production URLs in association domains capability, as well as PROD_appID.PROD_bundleID in apple-app-site-association file. Remember this file should be accessible by apple at
https://your-web.com/.well-known/apple-app-site-association
That's it, and further to play around with query parameters as well as dynamic paths, I would suggest seeing the above PDF link and especially the video on the official Apple site!

Try replacing "appID":".bundleid" with "appID":".bundleid" in your aasa file.

Related

iOS Universal Links not working within Safari but working from everywhere else

I managed to make Universal Linking working in our App 99% to perfection, but I'm still struggling to make it work reliably within Safari.
This is what happens:
If I get a link from either our www or non-www domain in Gmail, both launch the apps correctly;
If I write the URL from either our www or non-www domain in Notes, both launch the apps correctly;
In Safari / Chrome, only the links from the non-www domain launch the app reliably, 100% of the times;
In Safari / Chrome, the www version of our links sometimes launch the app, but always stop working after the first tap;
In Safari, if I longpress a www version of a link, it does show the "Open in App" context option;
I configured our app to handle both our wwww and non-www domains; we use React Native / Expo, so this is what we have under ios.associatedDomains:
"associatedDomains": [
"applinks:www.mydomain.com",
"applinks:mydomain.com"
]
Regarding the AASA, it's located on /.well-known/apple-app-site-association and returns context-type correctly (json):
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": ["MYTEAMID.com.ourcompany.ourfirstapp"],
"components": [
{
"/": "/first-app/path",
"comment": "Matches any URL whose path starts with /first-app/path"
}
]
},
{
"appID": "MYTEAMID.com.ourcompany.ourfirstapp",
"paths": [ "/first-app/path" ]
},
{
"appIDs": ["MYTEAMID.com.ourcompany.oursecondapp"],
"components": [
{
"/": "/second-app",
"comment": "Matches any URL whose path starts with /second-app"
}
]
},
{
"appID": "MYTEAMID.com.ourcompany.oursecondapp",
"paths": [ "/second-app" ]
}
]
},
"activitycontinuation": {
"apps": [
"MYTEAMID.com.ourcompany.ourfirstapp",
"MYTEAMID.com.ourcompany.oursecondapp"
]
}
}
I currently have no idea how to fix the safari/chrome behavior for the www domain links.
Finally found the answer. Quoting from the Branch documentation:
Universal Links will not work with a user-driven
element click on the same domain. For example, if there is a Universal
Link on google.com pointing to a different Universal Link on
google.com, it will not open the app.
In my case, the www links that didn't work were linked from a page I was hosting within the same www domain, so they were not expected to work at all.

Universal link does not work. Link validator tool displays error:Error no apps associated with url

I followed all the steps for adding universal link support for an app. But the option to open the app is never displayed.
The server hosts apple-app-site-association file with the following contents:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "teamID.bundleID'",
"paths": [ "/ios/meetings"]
}
]
}
}
Device logs for when app is installed:
swcd(CoreUtils)[216] : Completing request for 'https://example.com/.well-known/apple-app-site-association', status 0/0x0 noErr
swcd(CoreUtils)[216] : Updated app ID 'teamID.bundleID', domain '*.example.com', flags 0x0 < > -> 0x2 < SiteApproved > on check
Hitting URL: https://example.com/ through apps like mail, messages, notes, and safari always opens the link in the browser.
Link validator tool displays status passed but the section "Link to Application" displays an error: Error no apps associated with URL.
Can anyone tell me if I am missing anything?
Thanks in advance.
Try this.
1 set paths to ["*", "/"]
and
2 goto Project-->Targets-->Capabilities-->Associated Domain "ON"

iOS:Debuging universal links

I'm trying to implement universal links but for some reason when I load link from the domain I'm trying to redirect to my app is not working. Here is my apple-app-site-association file:
{
"applinks": {
"apps": ["44ABCDFG.com.myTeam.MyApp"],
"details": [{
"appID": "44ABCDFG.com.myTeam.MyApp",
"paths": ["*"]
}]
}
}
I add the domain in the Associated Domains:
Here is my implantation on app:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler{
NSLog(#"universal links are working!!!");
return true;
}
The links are http but per documentation it shouldn't be a issue. Also per documentation the apple-app-site-association is not necessary to be signed with SSL certificate.
I use apple validation tool and I'm getting this error: Error cannot fetch app site association
Any of you knows what I'm doing wrong or what can I do to make this work?
I'll really appreciate your help.
According to official document, https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
The apps key in an apple-app-site-association file must be present and its value must be an empty array, as shown in Listing 6-1.

iOS 9 universal links working. Exclusion path not working

There are several other posts which say universal links are not working. I have a different issue where these links are working, however I want to exclude some specific url's on my website from launching the app and this is not working.
As documented here:
https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
I have implemented the necessary steps for universal link including uploading the apple-app-site-association file.
The file looks like this example:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "AB1CDEFGHI.com.mydomain.myapp",
"paths": [ "*", "NOT /help/" ]
}
]
}
}
The intention here is if a user clicks www.mydomain.com/help it will not launch the app but open this page in safari. However this link opens the app.
I have tried several versions of this path including:
/help/*
/help/
/help
help
none of these provide the desired exclusion functionality.
Has anybody been able to implement this type of exclusion?
To answer my own question, by changing:
[ "*", "NOT /help/" ]
to:
[ "NOT /help/", "*" ]
It worked as expected. The order of the paths matters and by putting "*" first the system will find a match on the first path and will launch the app.
Simple enough...
You should use "NOT /help/" having the NOT inside the string.
Also, I suggest you look at AppsFlyer's solution for Universal Links. It may be a good alternative (using another applinks path).

The apple-app-site-association file format error

*I have error message from API Validation Tool from Apple*
**The apple-app-site-association file was found but it doesn’t follow the required format. Learn how to format the apple-app-site-association file.**
*My apple-app-site-association file:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TeamId.com.Company.AppName",
"paths": [
"/path1-*",
"/path2",
"/path3-*",
"/path4"
]
}
]
}
}
I saw this videos from WWDC 2015 "Seamless linking to your Apps" and "Introducing Search API" and read this App Search Programming Guide.
My website have an SSL certificate (from Authority certified) and my apple-app-site-association is inside https://www.mywebsite.com/apple-app-site-association
I don't know what is wrong with the file. I think syntax error can be but I cant see it.*
seems like you should replace TeamId.com.Company.AppName with your REAL TeamId and REAL bundle id.
Look at this one for exmaple
https://routes.tips/apple-app-site-association
It`s nor signed, but working and passing validation
Dears
There is one more issue about TeamID, especially more than one apps in one accout.
Please use the App IDs prefix into your appID of app-app-site-assiciation.

Resources