Detailed Flutter Deep Links explanation? - ios

I can't get any part of deep linking working in my Flutter app. None of the documentation I can find on this is anywhere near adequate. eg none mention this, but it appears https://developer.apple.com/documentation/xcode/supporting-associated-domains?language=objc that I need to provide a file on my server? Nor is there any discussion I can find of that or in what way I need to set up an associated domain.
May app on launch directs to the login page of a local copy of my website. Following login, my site redirects to myappname:mywebsite.
In my Info.plist, I have:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>mywebsite</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myappname</string>
</array>
</dict>
</array>
Following a tip from someone on reddit (as I say, this stuff isn't documented anywhere!), I added an associated domain in XCode applinks:mywebsite?mode=developer
I also redirected my domain in my local hosts file to my local machine. I've verified in the browser in the iOS simulator that the domain redirect is working in the simulator.
It appears from Apple's documentation that I should see a hit on my website to .well-known/apple-app-site-association but I get nothing.
My app successfully redirects on launch to the login page, but when I complete the login, my site issues a redirect to myappname://mywebsite but the browser in the simulator is just ignoring this.
I opened the console on the device browser from Safari, but nothing is reported.

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

IOS realease ITMS-90117: Missing routing app coverage file

My IOS app is using the map function for showing route and following is the map related configuration from info.plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>MKDirectionsRequest</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.maps.directionsrequest</string>
</array>
</dict>
</array>
<key>MKDirectionsApplicationSupportedModes</key>
<array>
<string>MKDirectionsModeBike</string>
<string>MKDirectionsModeBus</string>
<string>MKDirectionsModeCar</string>
<string>MKDirectionsModePedestrian</string>
</array>
The app is only focusing on sweden, and following is the "sweden.geojson" file. Where coordinates start with longitude then latitude, with three brackets to close a polygon. Last coordinate is same as the first one.
{
"type": "MultiPolygon",
"coordinates": [
[[[9.755,54.977],[24.960,54.977],[24.960,69.565],[9.755,69.565],[9.755,54.977]]]
]
}
The initial json format validation passes, so I can do the submit, but then I got the emails with error: invalid binary, IOS realease ITMS-90117: Missing routing app coverage file. I even tried the sample json file from apple documentation but it is same error. Been on apple developer forum searching, but it is only problem posting, and no one posts any solution. Help appreciated...
This may or may not help you as I don't know the purpose of your app, but I had the same problem and and have found a solution that works for me.
I use MapKit to provide directions inside the app, but it isn't a directions app.
The solution was to turn off Map from the app capabilities (on the Signing and Capabilities tab). This setting indicates that the app works as a general purpose directions app.
I'm theorizing (but don't know for sure) that the reason the binary was invalid before I turned off the Map capability was that you can't have the capability enabled without providing a way to start the app with a location.

Custom URL works in simulator but not on a device

I went through and followed this tutorial to use Custom URL. Everything works as expected on Simulator, so when I use safari and hit myApp:// a dialog pops up asking if I wish to open the app. SO far so good. However, when I installed the app on a device and hit the same thing in safari I get an error saying Cannot open page. Safari cannot open the page because the address is invalid. I tried this enough times, so it's definitely not a typing error. Any help is greatly appretiated.
.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.xyz.myApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>iOSMyApp</string>
</array>
</dict>
</array>
I copied my bundle identifier for CFBundleURLName.
ANSWER: So just before I was about to bang my head on the desk what I found that it's working when I open a new tab in Safari and then hit the app URL. And I have no idea why this happens. Also if you cancel it and then hit the app URL in the same tab again, it will give you an error I mentioned in the question. So the trick is to hit the app URL in a fresh tab everytime.
This setup is working for me. One thing I have to do is close the current tab of safari and open new one and type
iOSMyApp://

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.

CFBundleUrlTypes visible in the Info.plist but not in the XCode view of it

I am debugging my integration of Facebook iOS SDK 4.10 on iOS 9 (it works but the login is always done through a webview and doesn't open the Facebook app).
I have a problem with CFBundleUrlTypes, I have added it (many times) through XCode: Project > Info > Url Types... In fact it is persisted, because I can: cat Info.plist|grep -C 10 -i urltypes and get:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb$(FACEBOOK_APP_ID)</string>
</array>
</dict>
</array>
But I relaunch XCode it's not visible anymore in the project info.
Starting from iOS9, Facebook uses the Safari View Controller for Login rather than a fast app switch. The SDK basically tries to determine the best possible experience for the user so this is probably why you are always routed to the web based login.
It is also partly to get around the "APPNAME wants to open OTHERAPP" you will see in iOS9.
The documentation slightly touches on this here https://developers.facebook.com/docs/ios/ios9#faq

Resources