簡體   English   中英

網址欄未隱藏

[英]URL Bar is not Hiding

我們正在開發PWA應用程序,以將其提交到Play商店。 我們使用TWA,遵循所有概念,但以某種方式無法設法隱藏URL BAR。

數字資產鏈接已配置和測試。 我們已將網站與TWA連接起來,我們已成功測試了映射編輯器,我們添加了意圖過濾器,並成功測試了與assetlinks.json的關聯

Android清單

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="eu.clubforceone.mobile">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/appName"
        android:supportsRtl="true"
        android:theme="@style/Theme.LauncherActivity">

        <meta-data
            android:name="asset_statements"
            android:resource="@string/assetStatements" />

        <activity
            android:name="android.support.customtabs.trusted.LauncherActivity"
            android:label="@string/appName">
            <tools:validation testUrl="https://login.clubforce.eu" />

            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="@string/launchUrl" />

            <meta-data
                android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
                android:resource="@color/colorPrimary" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_IMAGE_DRAWABLE"
                android:resource="@drawable/splash" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_SCREEN_BACKGROUND_COLOR"
                android:resource="@color/whiteColor" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_SCREEN_FADE_OUT_DURATION"
                android:value="300" />

            <meta-data
                android:name="android.support.customtabs.trusted.FILE_PROVIDER_AUTHORITY"
                android:value="@string/providerAuthority" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <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="login.clubforce.eu" />
            </intent-filter>
        </activity>

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="@string/providerAuthority"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>

        <service
            android:name="android.support.customtabs.trusted.TrustedWebActivityService"
            android:enabled="@bool/enableNotification"
            android:exported="@bool/enableNotification">

            <intent-filter>
                <action android:name="android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>

    </application>
</manifest>

build.gradle模塊應用

apply plugin: 'com.android.application'

def twaManifest = [
        applicationId: 'eu.clubforceone.mobile',
        hostName: 'login.clubforce.eu', // The domain being opened in the TWA.
        launchUrl: '/', // The start path for the TWA. Must be relative to the domain.
        name: 'Clubforce', // The name shown on the Android Launcher.
        themeColor: '#283795', // The color used for the status bar.
        backgroundColor: '#F6F6F6', // The color used for the splash screen background.
        whiteColor: '#FFFFFF', // The color used for the splash screen background.
        enableNotifications: false // Set to true to enable notification delegation
]

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "eu.clubforceone.mobile"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 20003
        versionName '2.2'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        // The name for the application on the Android Launcher
        resValue "string", "appName", twaManifest.name

        // The URL that will be used when launching the TWA from the Android Launcher
        resValue "string", "launchUrl", "https://" + twaManifest.hostName + twaManifest.launchUrl

        // The hostname is used when building the intent-filter, so the TWA is able to
        // handle Intents to open https://svgomg.firebaseapp.com.
        resValue "string", "hostName", twaManifest.hostName

        // This variable below expresses the relationship between the app and the site,
        // as documented in the TWA documentation at
        // https://developers.google.com/web/updates/2017/10/using-twa#set_up_digital_asset_links_in_an_android_app
        // and is injected into the AndroidManifest.xml
        resValue "string", "assetStatements",
                '[{ \\"relation\\": [\\"delegate_permission/common.handle_all_urls\\"],' +
                        '\\"target\\": {\\"namespace\\": \\"web\\", \\"site\\": \\"https://' +
                        twaManifest.hostName + '\\"}}]'

        // This attribute sets the status bar color for the TWA. It can be either set here or in
        // `res/values/colors.xml`. Setting in both places is an error and the app will not
        // compile. If not set, the status bar color defaults to #FFFFFF - white.
        resValue "color", "colorPrimary", twaManifest.themeColor

        // Sets the color for the background used for the splash screen when launching the
        // Trusted Web Activity.
        resValue "color", "backgroundColor", twaManifest.backgroundColor

        // used only for specific situation where white color is needed
        resValue "color", "whiteColor", twaManifest.whiteColor


        // Defines a provider authority fot the Splash Screen
        resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'

        // The enableNotification resource is used to enable or disable the
        // TrustedWebActivityService, by changing the android:enabled and android:exported
        // attributes
        resValue "bool", "enableNotification", twaManifest.enableNotifications.toString()
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:91b4a1270b511ce70245d3440e6267762c5f1c6b'
}

assetLinks.json

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "eu.clubforceone.mobile",
    "sha256_cert_fingerprints":
    ["CD:D5:D1:54:AC:8F:17:0B:8A:E6:5D:0F:C2:07:1D:FC:D7:2C:16:EE:66:A4:D9:F6:DA:1C:57:12:1B:57:A5:F9"]
  }
}]

我不知道該怎么辦...

這是我從運行“ keytool -list -printcert -jarfile app-release.apk”得到的結果

Signer #1:

Signature:

Owner: deleted for privacy reason
Issuer: deleted for privacy reason
Serial number: 6beb859e
Valid from: Sun Apr 01 14:33:45 CEST 2018 until: Thu Aug 17 14:33:45 CEST 2045
Certificate fingerprints:
     MD5:  29:FC:96:6C:FC:D0:E4:69:BC:BC:B1:95:01:DA:6D:2D
     SHA1: 00:7E:76:27:F9:5E:51:83:6A:77:70:57:90:A1:B7:56:66:66:A3:99
     SHA256: CD:D5:D1:54:AC:8F:17:0B:8A:E6:5D:0F:C2:07:1D:FC:D7:2C:16:EE:66:A4:D9:F6:DA:1C:57:12:1B:57:A5:F9
     Signature algorithm name: SHA256withRSA
     Version: 3

Extensions: 

#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 06 A2 63 AE E8 BD 9A 56   00 66 4E 8B 9C 09 EA 13  ..c....V.fN.....
0010: 20 C8 E5 4E                                         ..N
]
]

您可以使用PWA2APK簡化過程: PWA2APK

“ assetlinks.json”文件中的“ package_name”字段需要指向應用程序的程序包名稱(與applicationId相同)。

這是assetlinks.json文件的外觀:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "eu.clubforceone.mobile",
    "sha256_cert_fingerprints":
    ["CD:D5:D1:54:AC:8F:17:0B:8A:E6:5D:0F:C2:07:1D:FC:D7:2C:16:EE:66:A4:D9:F6:DA:1C:57:12:1B:57:A5:F9"]
  }
}]

如果您要讓Play商店管理簽名,請檢查您的assetlinks.json是否包含Play商店設置中的SHA215,而不是keytool生成的SHA215。 其他答案所述

也就是說,我和你的處境相同。 我也無法從TWA應用中刪除網址欄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM