MAUI IOS App universal links don't open my application - ios

I am trying to start my MAUI IOS App using URI, but when I clicked on URL that must open my app nothing happen. I set a breakpoint into OpenUrl and ContinueUserActivity to check if its called, but its never called.
I created apple-app-site-association :
{
"applinks": {
"apps": [],
"details": [
{
"appID": "H9375ODJ26.com.example.testapp",
"paths": [ "/video/*"]
}
]
}
}
the file is accessible on https://www.example.com/.well-known/apple-app-site-association and it has content-type = application/json.
I have added in my Entitlements.plist this code:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:example.com</string>
</array>
In developer.apple.com Associated domains option for my app is turned on.
Can anyone tell me what I'm missing ? I expect when I click on the URI, a pop-up will appear asking how to open the uri - browser or my ios app.

In Maui you can use Launcher to open other applications through URI. Apple requires that you define the schemes you want to use. Add the LSApplicationQueriesSchemes key and schemes to the Info.plist files:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>XXX</string>
</array>
Call the ILauncher.OpenAsync method and pass in a String or Uri representing the application to open:
await Launcher.Default.OpenAsync("xxx");
For more details, refer to:Launcher | Microsoft

Related

How to make deep links work in flutter when opened with gmail?

I am trying to implement deep linking in my flutter app. I am using the uni_links flutter package.
I am sending the deeplink for my application to the user's email account. However, in gmail, you need the http protocol in the href value, Otherwise gmail will not consider that as a valid link. Hence I am forced to use the following link in the email :
Click here
as opposed to a link like,
Click here
Now with https://myexample.flutter.dev, when I open the link from gmail, it doesn't open my app.
But, if I change my CFBundleURLSchemes key to myexample and CFBundleURLName to flutter.dev, when I type in myexample://flutter.dev in my browser, it opens my app. However, like I mentioned before, this is not recognized as a valid link in gmail.
What is the issue here? How do I resolve this?
Here's my ios/Runner/Info.plist :
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>myexample.flutter.dev</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
</array>
The first one is custom link you can do it by yourself
Click here
The second one is universal link
You need to provide file on the backend side to make it work.
Universal Links only work with https scheme and require a specified host, entitlements and a hosted file - apple-app-site-association.
Click here
UniversalLinksDocumentation
PS. I think right now as the end of the 2020 the best way to handle deeplinks is by Firebase Dynamic Links. Maybe future people will consider it it should be much more easier

Opening all links from iPhone gmail app opens my app

We have the odd situation where the iPhone app we've developed in Xamarin Forms is somehow intercepting all links in the Gmail app's emails, not just the links we intend our app to process. The user taps any link, and Gmail opens the link directly in our app instead of opening it in chrome or safari.
The only way to prevent this behavior is to go into Gmail settings and set Safari as the default browser.
Is this something that could be caused by an incorrect apple-app-site-association file?
This is the association file we are using for a domain where we process all paths in that domain. Other association files on other domains are more specific (specifying subpaths).
{
"applinks": {
"apps": [],
"details": [
{
"appID": "xxx.yyy",
"paths": [ "/", "" ]
}
]
}
}
We found the solution to the problem. A change had been made to the info.plist file in the iOS project, which caused our app to process Google Chrome links from Gmail. The googlechromes entry was the cause.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>googlechromes</string>
</array>
</dict>
</array>

Apple-app-site-association file not linking to application

Even after 48 hours, as said in apple documentation, apple-app-site-association is not working in my application. I have checked with [apple validation tools] (https://search.developer.apple.com/appsearch-validation-tool/) but its showing Error no apps associated with url in the Link to Application. Here is the format of my apple-app-site-association file
{
"applinks": {
"apps": [],
"details": [{
"appID": "{team_id}.{bundle_id}",
"paths": ["*"]
}]
}
}
I have also enabled Associated Domains for the appId from developer.apple.com and in the XCode capabilities settings also.
I have already tried [this] (iOS Universal Links not working via TestFlight)
Also check the Apple Developer Forum but couldn't find a solution there also.
Little late to this thread but if you want Apple to call your app-site-association file each time the app is installed, simply do this:
applinks:[domain]?mode=developer
This way you can change the settings of the file while developing!
Make sure you are following these steps
Enabled Associated Domains in the app App services from the developer.apple.com
Set the domain name correctly in the Associated Domains in the Xcode capabilities and also enabled this.
You have correctly generated the apple-app-site-association file. The file must not have any extension. Here is the format for the file:
{
"applinks": {
"apps": [],
"details": [{
"appID": “{app_prefix}.{your_app_bundle_identifier}”,
"paths": ["*"]
}]
}
}
Make sure apps tag in the file is be empty and appID is made up of your app Prefix and bundle identifier separated by.
NOTE: I don't know why but I am using app prefix instead teamID as mentioned in most of the posts and even on the apple documentation. But it didn't work for me.
You can also try by using app prefix of the app id instead of teamID

Allow opening my app from a link in a third-party app

I'm currently using a custom URL scheme to allow users to access my app (say, FoobarApp) from custom links (foobar://resource/42).
I set up the scheme like so :
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.acme.foobarapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>foobar</string>
</array>
</dict>
</array>
This works well when the users click the link in Safari.
Now I'd like them to be able to click said links in third-party apps (in my case Trello), to open my app.
This does not work, as the system (since iOS 9 if I'm not mistaken) now requires that apps whitelist URL scheme they want to query (with the LSApplicationQueriesSchemes in Info.plist).
(This is the message I get in the logs when I click the link in the third-party app:
iPad Trello(UIKit)[2368] : -canOpenURL: failed for URL: "foobar://resource/42" - error: "This app is not allowed to query for scheme foobar"
)
It's not reasonable to expect the third-party app to add my (enterprise) app's scheme to their LSApplicationQueriesSchemes list. Is their any option to "bypass" this protection? A kind of way to tell the system "It's fine, Trello can open my app"?
Summary
Custom app links foobar:// work in Safari
They don't work in third-party app (nothing happens, see log a few lines up)
How can I whitelist third-party apps so they can open my app?
an app has to tell ios it wants to query a url scheme. It has to declare this in its info plist at compile time!
There is no way around this on a apple allowed iPhone.
Sure when you jailbreak a phone, all can be done but... thats not a valid assumption either ;)
a workaround may be to link to a Website via HTTP and have the user open the app from there.

How to open URL schemes from Safari in iOS9?

I was able to open apps from safari this way:
window.location = 'myapp://do/xx';
or open facebook app:
window.location = 'fb://';
But this stopped working in iOS9.
How can I open apps using URL schemes in safari?
IOS 9 URL Shchemes Update :
iOS 9 introduces LSApplicationQueriesSchemes to allow apps to query if other apps are installed.
1- If a url scheme is declared and calling canOpenURL(scheme)
YES if a installed app supports that URL scheme
NO if no app supporting that url
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
2- If a url scheme is not declared and calling canOpenURL(scheme)
always return NO
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
In iOS 9, the developer must add these info.plist
LSApplicationQueriesSchemes
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
50 max. unqiue URL scheme can be declared!
With iOS9, Apple is changing a few things concerning URL schemes. Here is an article about those changes.
Basically, you now have to register all URL schemes that are supported by your app in your .plist file.
With the general release of ios9 setting window.location to a custom url does launch the app, but only after the user hits open in a popup. I filed a bug with apple about this, and they responded saying that it was intended behavior for launching an app from safari. They said they would look into the issue where if you hit cancel it fails out on future attempts.
Just assign a desired address to the href property, instead of trying to replace the whole window.location object:
window.location.href = 'myapp://do/xx';
It works for me on iOS 9.0.2, but now safari shows a confirmation dialog to ensure а user really wants open your link in the app.
this is how I have revised my Facebook/Google Login integration to get it work on latest update. which now user Safari web view.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>com.googleusercontent.apps.39373238582-opjuqokmar2i5t3sdk2vs5sifer4moen</string>
<string>com-google-gidconsent-google</string>
<string>com-google-gidconsent-youtube</string>
<string>com-google-gidconsent</string>
<string>com.google.gppconsent.2.4.1</string>
<string>com.google.gppconsent.2.4.0</string>
<string>googlechrome</string>
<string>googlechrome-x-callback</string>
</array>

Resources