facebook twitter hatena line email

「Unity/URLからアプリ起動」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(確認方法)
(確認方法)
行99: 行99:
 
</pre>
 
</pre>
 
Webサーバに設置した直後だと、エラーになるが、しばらくすると動作するようになった。
 
Webサーバに設置した直後だと、エラーになるが、しばらくすると動作するようになった。
 +
 +
===本番のフィンガープリントの箇所===
 +
play.google.com/consoleの、テストとリリース/アプリの完全性/アプリの署名/アップロード鍵の証明書のSHA-1証明書のフィンガープリントがある。
  
 
===確認方法===
 
===確認方法===

2025年12月3日 (水) 10:49時点における版

Androidの場合

BuildProfilesのAndroid/PlayerSettingで、CustomMainManifestをonにする。

Assets/Plugins/Android/AndroidManifest.xml にintent-filterを追加する。

例として、ttps://example.com/hogehogeで起動させたい場合。

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application>
        <!--Used when Application Entry is set to Activity, otherwise remove this activity block-->
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
                  android:theme="@style/UnityThemeSelector">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />

        </activity>
        <!--Used when Application Entry is set to GameActivity, otherwise remove this activity block-->
        <activity android:name="com.unity3d.player.UnityPlayerGameActivity"
                  android:theme="@style/BaseUnityGameActivityTheme"
                  android:launchMode="singleTask"
                  android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
            <meta-data android:name="android.app.lib_name" android:value="game" />

            <!-- DeepLink / App Links -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="https"
                    android:host="example.com"
                    android:pathPrefix="/hogehoge" />
            </intent-filter>
        </activity>

    </application>
</manifest>

activityが、"com.unity3d.player.UnityPlayerActivity"と"com.unity3d.player.UnityPlayerGameActivity"があり、"com.unity3d.player.UnityPlayerGameActivity"側にintent-filterをつけた場合は、 Unity の Player Settings の "ApplicationEntryPoint" の GameActivity にチェックがついてることを確認。

activityの"com.unity3d.player.UnityPlayerGameActivity"側に、以下が追加されてることも確認。

android:launchMode="singleTask"
android:exported="true"

アプリのローカルフィンガープリント出力。

$ adb shell pm get-app-links com.example.app1
  com.example.app1:
    ID: fb90da74-68d4-40c7-a197-698907e476de
    Signatures: [D8:C9:8D:8D:E9:1F:3C:D8:97:DB:34:2B:D0:E9:66:76:70:28:B9:8B:37:44:32:E2:14:9E:CD:97:70:XX:XX:XX]
    Domain verification state:
      example.com: verified

Webサーバに、 example.com/.well-known/assetlinks.jsonを設置する。(例:example.comは適宜変更)

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.app1",
      "sha256_cert_fingerprints": [
        "D8:C9:8D:8D:E9:1F:3C:D8:97:DB:34:2B:D0:E9:66:76:70:28:B9:8B:37:44:32:E2:14:9E:CD:97:70:XX:XX:XX"
      ]
    }
  }
]

設置が正しいかcurlで確認。

$ curl -I https://example.com/.well-known/assetlinks.json
HTTP/2 200
server: nginx
date: Tue, 02 Dec 2025 22:05:04 GMT
content-type: application/json
content-length: 328
last-modified: Tue, 02 Dec 2025 21:56:17 GMT
etag: "148-644ff2a4d2500"
accept-ranges: bytes

Webサーバに設置した直後だと、エラーになるが、しばらくすると動作するようになった。

本番のフィンガープリントの箇所

play.google.com/consoleの、テストとリリース/アプリの完全性/アプリの署名/アップロード鍵の証明書のSHA-1証明書のフィンガープリントがある。

確認方法

アプリのブラウザで、以下のurlを開いて、アプリが起動すれば良い。

https://example.com/hogehoge

get-app-linksコマンドで、verifiedが出れば問題ないはず

adb shell pm get-app-links com.example.app1
  com.example.app1:
    ID: fb90da74-68d4-40c7-a197-698907e476de
    Signatures: [D8:C9:8D:8D:E9:1F:3C:D8:97:DB:34:2B:D0:E9:66:76:70:28:B9:8B:37:44:32:E2:14:9E:CD:97:70:XX:XX:XX]
    Domain verification state:
      example.com: verified