【问题标题】:TWA - Digital Asset Link OK but address bar still visibleTWA - 数字资产链接正常,但地址栏仍然可见
【发布时间】:2019-10-22 16:38:57
【问题描述】:

我开发了一个渐进式网络应用程序,我想将它作为受信任的网络活动发布到 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 删除到移动版本之前)但没有任何改变。地址栏仍然可见。

【问题讨论】:

  • 尝试生成一个发布APK并在您的手机上试用。地址栏不应该在那里。
  • 当我生成一个发布 APK 并将它安装到我的手机上时,地址栏仍然隐藏。问题是当我在 Store 上发布应用程序时。
  • 可能是 /mobile 有问题。未安装在根目录下时,我遇到了 pwa 问题。这只是一个想法。你可以试试mobile.bagnoadriatico.it 吗?
  • 我尝试使用 www.bagnoadriatico.it ,但我的 PWA 使用 302 http 代码将移动流量重定向到 /mobile。我认为 TWA 需要 200 个 http 代码。我可以试试 mobile.bagnoadriatico.it 我会告诉你的,谢谢
  • 我尝试将 launchUrl 设置为根目录(在我将 302 删除到移动版本之前),但没有任何改变。地址栏仍然可见。

标签: android gradle progressive-web-apps trusted-web-activity


【解决方案1】:

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

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

【讨论】:

  • 这太不可思议了!有用!在一年没有成功之后,我完全失去了希望。我完全按照谷歌的指导说明进行操作,但仍然没有用。这个应用程序太棒了。谢谢
  • @SimoVinci 不客气。您能否将此问题标记为已解决?
  • 很高兴你们中的一些人成功地做到了这一点。我想问一下你是否遇到过这个问题。我的assetlinks.json 测试正确。当我在模拟器中尝试时,twa 没有工具栏。但是如果我将它安装在我的设备中,它会说验证失败。想法?
  • @chitgoks 你试过在你的设备上使用上面的应用程序来生成一个新的assetlinks.json文件吗?
  • 我让它工作了。托管存在问题,因此仅允许 Web 浏览器查看文件,必须更改不同的托管服务提供商。但奇怪的是,在我的 72 版 chrome 模拟器中,它显示时没有工具栏。
【解决方案2】:

assetlinks.jsonfile 实际上是错误的。它包含 Android 标记网络标记:

[{
  "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 时没有重定向到未验证的域。

如果有任何帮助,请告诉我。

【讨论】:

  • 我如你所说更改了文件,删除了网络标记。不幸的是,一切都没有改变。我确定没有重定向。我直接从谷歌游戏控制台获取了指纹。还有什么我可以做的吗?我想在夏天之前宣传我的申请:(
【解决方案3】:

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

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

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

Source

【讨论】:

    猜你喜欢
    • 2022-12-01
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 2020-02-07
    • 1970-01-01
    相关资源
    最近更新 更多