7

我开发了一个渐进式 Web 应用程序,我想将它作为受信任的 Web 活动发布到 Play 商店。这是https://www.bagnoadriatico.it

按照本指南 https://developers.google.com/web/updates/2019/02/using-twa

我从https://github.com/GoogleChromeLabs/svgomg-twa下载了示例

我改变了配置

def twaManifest = [
    applicationId: 'com.simovinci.bagnoadriatico',
    hostName: 'www.bagnoadriatico.it', // The domain being opened in the TWA.
    launchUrl: '/mobile', // The start path for the TWA. Must be relative to the domain.
    name: 'BagnoAdriatico di Casalborsetti', // The name shown on the Android Launcher.
    themeColor: '#ff5c14', // The color used for the status bar.
    backgroundColor: '#ffff00' // The color used for the splash screen background.
]

然后我签署了apk,构建并在Play商店发布。

在我通过 Digital Asset Link https://www.bagnoadriatico.it/.well-known/assetlinks.json创建关联的网站中 ,“Statement List Generator and Tester”说操作成功“成功!主机 www.bagnoadriatico .it 授予应用程序与 com.simovinci.bagnoadriatico 的深度链接。” https://developers.google.com/digital-asset-links/tools/generator

地址栏仍然可见,我不知道为什么。

https://www.bagnoadriatico.it/mobile返回 200 http 代码。PWA 经过 100% Lighthouse 验证。关键指纹是对的

=========================================

我尝试设置 launchUrl = "/" (在我将 302 删除到移动版本之前)但没有任何改变。地址栏仍然可见。

4

3 回答 3

10

如果您使用了 Google Play 的应用签名,您的 SHA 256 会发生变化。解决方法是从 Play 商店下载您的应用,然后使用 Play 商店中的以下工具生成一个新的assetlinks.json 文件:

https://play.google.com/store/apps/details?id=dev.conn.assetlinkstool&hl=en

于 2020-05-10T17:37:05.270 回答
1

assetlinks.json文件实际上是错误的。它包含 Android 标记Web 标记:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "web",
    "site": "https://www.bagnoadriatico.it"
  }
},{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target" : { "namespace": "android_app", "package_name": "com.simovinci.bagnoadriatico",
               "sha256_cert_fingerprints": ["DA:E2:7C:57:8F:B8:28:ED:C0:00:70:7C:52:1F:95:8E:50:E6:A9:58:50:B0:FB:9A:F1:99:78:C9:D4:6B:72:45"] }
}]

assetlinks.json包含以下语句就足够了:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target" : { "namespace": "android_app", "package_name": "com.simovinci.bagnoadriatico",
               "sha256_cert_fingerprints": ["DA:E2:7C:57:8F:B8:28:ED:C0:00:70:7C:52:1F:95:8E:50:E6:A9:58:50:B0:FB:9A:F1:99:78:C9:D4:6B:72:45"] }
}]

我不确定这是否是地址栏可见的根本原因。我还建议仔细检查:

  • 仔细检查指纹
  • 确保在打开 URL 时没有重定向到未验证的域。

让我知道这些是否有帮助。

于 2019-06-19T06:59:09.117 回答
0

我只在模拟器上发现了这个问题。它在真实设备上完美运行。

问题是模拟器不加载签名的 APK。要在模拟器上加载签名的 apk,请在 gradle 文件中添加以下代码

signingConfigs{
        debug{
            keyAlias 'your key alias'
            keyPassword 'your keypassword'
            storeFile file('keystore path')
            storePassword 'your storepassword'
        }
    }
    buildTypes {
        debug{
            signingConfig signingConfigs.debug
        }
 }  

来源

于 2021-05-17T07:43:15.367 回答