diff --git a/.github/workflows/ios-signed.yml b/.github/workflows/ios-signed.yml
index 8d97f727..9d170357 100644
--- a/.github/workflows/ios-signed.yml
+++ b/.github/workflows/ios-signed.yml
@@ -247,6 +247,26 @@ jobs:
fi
echo "IPA signing verified."
+ # Universal Links (#1329). Without this entitlement in the signed app, iOS
+ # never fetches apple-app-site-association and offband.app links open in
+ # Safari, with no build error. Checked against a wrong domain first, so it
+ # is shown able to fail on every run.
+ - name: Verify the IPA claims the offband.app link domains
+ run: |
+ set -eu
+ ENT="$(codesign -d --entitlements :- "${APP}" 2>/dev/null)"
+ if printf '%s\n' "${ENT}" | grep -qF "applinks:not-this-domain.example"; then
+ echo "::error::The entitlement check accepted a wrong domain."
+ exit 1
+ fi
+ for domain in offband.app dev.offband.app; do
+ if ! printf '%s\n' "${ENT}" | grep -qF "applinks:${domain}"; then
+ echo "::error::The signed app does not claim applinks:${domain}."
+ exit 1
+ fi
+ done
+ echo "Associated domains present in the signed app."
+
- name: Install the App Store Connect API key
env:
ASC_API_KEY_P8_BASE64: ${{ secrets.ASC_API_KEY_P8_BASE64 }}
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 7f9974fa..0873daf9 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -446,6 +446,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -625,6 +626,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -647,6 +649,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements
new file mode 100644
index 00000000..974ac8bb
--- /dev/null
+++ b/ios/Runner/Runner.entitlements
@@ -0,0 +1,11 @@
+
+
+
+
+ com.apple.developer.associated-domains
+
+ applinks:offband.app
+ applinks:dev.offband.app
+
+
+
diff --git a/test/platform/share_link_registration_test.dart b/test/platform/share_link_registration_test.dart
index eb2c7e3b..c552dddb 100644
--- a/test/platform/share_link_registration_test.dart
+++ b/test/platform/share_link_registration_test.dart
@@ -101,6 +101,56 @@ void main() {
);
});
+ test('iOS claims offband.app links for Offband (#1329)', () {
+ final entitlements = _read('ios/Runner/Runner.entitlements');
+ final domains = RegExp(
+ r'com\.apple\.developer\.associated-domains\s*([\s\S]*?)',
+ ).firstMatch(entitlements);
+ expect(domains, isNotNull, reason: 'associated-domains entitlement');
+ expect(
+ RegExp(
+ r'([^<]*)',
+ ).allMatches(domains![1]!).map((m) => m[1]).toList(),
+ ['applinks:offband.app', 'applinks:dev.offband.app'],
+ );
+ // Debug, Release and Profile of the Runner target. Without the setting,
+ // Xcode signs the app with no entitlement and iOS never asks the site.
+ expect(
+ 'CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;'
+ .allMatches(_read('ios/Runner.xcodeproj/project.pbxproj'))
+ .length,
+ 3,
+ );
+ });
+
+ test('apple-app-site-association names Offband for /add/ (#1329)', () {
+ final aasa =
+ jsonDecode(_read('web/.well-known/apple-app-site-association'))
+ as Map;
+ final details =
+ (aasa['applinks'] as Map)['details'] as List;
+ expect(details, hasLength(1));
+ final entry = details.single as Map;
+ // Team ID from the App Store profile, and the iOS bundle id, which ends
+ // in .ios unlike Android's.
+ expect(entry['appIDs'], ['63VU9LBN3A.app.offband.meshcore.ios']);
+ expect(entry['components'], [
+ {'/': '/add/*'},
+ ]);
+ });
+
+ test('apple-app-site-association is served as JSON (#1329)', () {
+ expect(
+ _read('web/_headers'),
+ matches(
+ RegExp(
+ r'^/\.well-known/apple-app-site-association\r?\n\s+Content-Type: application/json',
+ multiLine: true,
+ ),
+ ),
+ );
+ });
+
test('macOS opens meshcore:// links in Offband', () {
expect(
_plistDeclaresScheme(_read('macos/Runner/Info.plist'), 'meshcore'),
diff --git a/web/.well-known/apple-app-site-association b/web/.well-known/apple-app-site-association
new file mode 100644
index 00000000..17e1383b
--- /dev/null
+++ b/web/.well-known/apple-app-site-association
@@ -0,0 +1,10 @@
+{
+ "applinks": {
+ "details": [
+ {
+ "appIDs": ["63VU9LBN3A.app.offband.meshcore.ios"],
+ "components": [{ "/": "/add/*" }]
+ }
+ ]
+ }
+}
diff --git a/web/_headers b/web/_headers
index ce8fe760..c47539dc 100644
--- a/web/_headers
+++ b/web/_headers
@@ -28,6 +28,11 @@
/.well-known/assetlinks.json
Content-Type: application/json
+# Universal Links (#1329). iOS reads this file, which has no extension, to
+# confirm the app may open offband.app/add/... links.
+/.well-known/apple-app-site-association
+ Content-Type: application/json
+
/*
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp