avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
563 stars 303 forks source link

IOS universal links are not working #111

Open eltiganiomar opened 3 years ago

eltiganiomar commented 3 years ago

I would like to use universal links but I can't get it to work. I tried Android App Links and IOS Custom Url schemes and they worked fined. However IOS Universal Links don't work for me. I created the Runner.entitlements file followed the readme file but it doesn't work.

I tried it on IOS Simulator and on a real IPhone SE device. Did anyone detect the same problem?

cloudbreakstudios commented 3 years ago

I had a few issues which I seemed to resolve by doing the following..

Say I had an email/sms link with https://123.com/test/?param1=abc

My apple Runner.entitlement com.apple.developer.associated-domains key would be - applinks:123.com

Then on my website, I create a .well-known folder with the following files..

apple-app-site-association containing.. { "applinks": { "apps": [], "details": [ { "appID": "<app_id>.com.123.myapp", "paths": [ "/test/*" ] } ] } }

You can get the app_id off of apple developer site. It is worth reading through this page as it helped me a lot.. https://abhimuralidharan.medium.com/universal-links-in-ios-79c4ee038272

assetlinks.json containing..

[ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace": "android_app", "package_name": "com.123.myapp", "sha256_cert_fingerprints": [ "MY_SHA256_CERT_FOUND_ON_GOOGLE_DEVELOPER_CONSOLE" ] } } ]

I think the next bit is key..

I also created a .htaccess file containing <Files "apple-app-site-association"> ForceType 'application/json' </Files>

Then in first page i do..

` String _param1;

@override void initState() { super.initState(); initUniLinks(); }

Future initUniLinks() async { try { _param1 = ''; final _initialLink = await getInitialLink(); print('initial link: $_initialLink'); if (_initialLink != null) { final _initialUri = Uri.parse(_initialLink); //_initialUri.queryParameters.forEach((k,v) => print(k + " - " + v)); _param1 = _initialUri.queryParameters['param1']; } } on PlatformException { print('Failed to get initial link.'); } on FormatException { print('Failed to parse the initial link as Uri.'); } }

`

Next uninstall any existing version of the app you have already built and run on the device and reinstall. If it doesn't work, I also found restarting the device helped!

shabeenabarde commented 2 years ago

I had a few issues which I seemed to resolve by doing the following..

Say I had an email/sms link with https://123.com/test/?param1=abc

My apple Runner.entitlement com.apple.developer.associated-domains key would be - applinks:123.com

Then on my website, I create a .well-known folder with the following files..

apple-app-site-association containing.. { "applinks": { "apps": [], "details": [ { "appID": "<app_id>.com.123.myapp", "paths": [ "/test/*" ] } ] } }

You can get the app_id off of apple developer site. It is worth reading through this page as it helped me a lot.. https://abhimuralidharan.medium.com/universal-links-in-ios-79c4ee038272

assetlinks.json containing..

[ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace": "android_app", "package_name": "com.123.myapp", "sha256_cert_fingerprints": [ "MY_SHA256_CERT_FOUND_ON_GOOGLE_DEVELOPER_CONSOLE" ] } } ]

I think the next bit is key..

I also created a .htaccess file containing <Files "apple-app-site-association"> ForceType 'application/json' </Files>

Then in first page i do..

` String _param1;

@OverRide void initState() { super.initState(); initUniLinks(); }

Future initUniLinks() async { try { _param1 = ''; final _initialLink = await getInitialLink(); print('initial link: $_initialLink'); if (_initialLink != null) { final _initialUri = Uri.parse(_initialLink); //_initialUri.queryParameters.forEach((k,v) => print(k + " - " + v)); _param1 = _initialUri.queryParameters['param1']; } } on PlatformException { print('Failed to get initial link.'); } on FormatException { print('Failed to parse the initial link as Uri.'); } }

`

Next uninstall any existing version of the app you have already built and run on the device and reinstall. If it doesn't work, I also found restarting the device helped!

Where did you keep this file?