ディープリンク
ディープリンク URL を処理する
概要
外部からアプリを開いたり、アプリ内の特定の画面に移動したりするディープリンクをサポートします。
| 機能 | Android | iOS |
|---|---|---|
| カスタムスキームのディープリンク | ✓ | ✓ |
| App Links(HTTPS) | ✓ | ✓(Universal Links) |
対応プラン: Basic 以上
ディープリンクスキームの構成
ビルド Flavor ごとのデフォルトのディープリンクスキーム:
| Flavor | デフォルトスキーム |
|---|---|
| Basic | unveily-basic:// |
| Standard | unveily-standard:// |
| Pro | unveily-pro:// |
カスタムスキームは app/build.gradle.kts の deepLinkScheme プレースホルダーで変更します。
ディープリンク URL の例
unveily-basic://product?id=1234
unveily-basic://user/profileディープリンクの受信処理
アプリがディープリンクで開かれるとイベントが発生します。
window.addEventListener('unveily-event', (e) => {
if (e.detail.type === 'deeplink') {
const { url } = e.detail.data;
handleDeepLink(url);
}
});
function handleDeepLink(url) {
const parsed = new URL(url);
const path = parsed.pathname; // "/product"
const params = parsed.searchParams;
if (path === '/product') {
const productId = params.get('id');
window.location.href = `/product/${productId}`;
}
}App Links(HTTPS ディープリンク)
Android App Links を使うと、https://your-domain.com/path 形式の URL でアプリを開けます。
1. assetlinks.json をサーバーに配置する
/.well-known/assetlinks.json のパスでアクセスできる必要があります。
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.yourcompany.app",
"sha256_cert_fingerprints": ["AA:BB:CC:DD:..."]
}
}]sha256_cert_fingerprints は Google Play Console の アプリの署名 セクションで確認できます。
iOS Universal Links の設定
iOS で HTTPS URL を使ってアプリを開くには、Universal Links を設定する必要があります。
1. apple-app-site-association ファイルをサーバーに配置する
/.well-known/apple-app-site-association のパスに拡張子なしで JSON ファイルを配置し、Content-Type: application/json で返す必要があります。
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TEAMID.com.yourcompany.app",
"paths": ["/product/*", "/user/*"]
}
]
}
}appID は {Apple Team ID}.{Bundle ID} の形式です。Team ID は Apple Developer コンソールの Membership セクションで確認できます。
2. Xcode で Associated Domains を有効にする
Xcode → Signing & Capabilities → Associated Domains を追加し、ドメインを入力します。
applinks:your-domain.comサーバーから assetlinks.json を提供する
app.get('/.well-known/assetlinks.json', (req, res) => {
res.json([{
relation: ['delegate_permission/common.handle_all_urls'],
target: {
namespace: 'android_app',
package_name: 'com.yourcompany.app',
sha256_cert_fingerprints: [process.env.APP_CERT_FINGERPRINT]
}
}]);
});app.MapGet("/.well-known/assetlinks.json", () => new[] {
new {
relation = new[] { "delegate_permission/common.handle_all_urls" },
target = new {
@namespace = "android_app",
package_name = "com.yourcompany.app",
sha256_cert_fingerprints = new[] { Environment.GetEnvironmentVariable("APP_CERT_FINGERPRINT") }
}
}
});@GetMapping("/.well-known/assetlinks.json")
public ResponseEntity<List<Map<String, Object>>> assetLinks() {
return ResponseEntity.ok(List.of(Map.of(
"relation", List.of("delegate_permission/common.handle_all_urls"),
"target", Map.of(
"namespace", "android_app",
"package_name", "com.yourcompany.app",
"sha256_cert_fingerprints", List.of(certFingerprint)
)
)));
}<?php
if ($_SERVER['REQUEST_URI'] === '/.well-known/assetlinks.json') {
header('Content-Type: application/json');
echo json_encode([[
'relation' => ['delegate_permission/common.handle_all_urls'],
'target' => [
'namespace' => 'android_app',
'package_name' => 'com.yourcompany.app',
'sha256_cert_fingerprints' => [$_ENV['APP_CERT_FINGERPRINT']]
]
]]);
exit;
}<%
Response.ContentType = "application/json"
Dim fingerprint
fingerprint = Application("AppCertFingerprint")
Response.Write "[{""relation"":[""delegate_permission/common.handle_all_urls""]," & _
"""target"":{""namespace"":""android_app""," & _
"""package_name"":""com.yourcompany.app""," & _
"""sha256_cert_fingerprints"":[""" & fingerprint & """]}}]"
%>