javascript - 当用户单击推送通知时打开 TWA 应用程序而不是 Web 应用程序
问题描述
当前行为:当用户单击推送通知时,Web 应用程序打开,即使 TWA 应用程序安装在 android 手机中。
预期行为:当用户单击推送通知时,我想打开 TWA(受信任的网络活动)应用程序。
我正在使用 Firebase 进行推送通知
我只是使用 google 的示例 repo ( https://github.com/GoogleChromeLabs/svgomg-twa ) 作为我的基础并覆盖它。
当用户单击通知时我尝试打开的 URL 类似于https://dev.example.com/
这是我的 AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<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" />
<meta-data
android:name="cros_web_alternative"
android:value="@string/crosLaunchUrl" />
<activity android:name="android.support.customtabs.trusted.LauncherActivity"
android:label="@string/appName">
<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.NAVIGATION_BAR_COLOR"
android:resource="@color/navigationColor" />
<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/backgroundColor"/>
<meta-data android:name="android.support.customtabs.trusted.SPLASH_SCREEN_FADE_OUT_DURATION"
android:value="@integer/splashScreenFadeOutDuration"/>
<meta-data android:name="android.support.customtabs.trusted.FILE_PROVIDER_AUTHORITY"
android:value="@string/providerAuthority"/>
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
<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="@string/hostName"/>
</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>
解决方案
这似乎是 Chrome 80 中引入的错误。
检查此铬错误以获取更多详细信息: https ://bugs.chromium.org/p/chromium/issues/detail?id=1052288
推荐阅读
- javascript - 在 React 打字稿的 useState 挂钩中使用 PrevState
- spring-data-mongodb - 具有相似条件的 MongoDb 查询给出错误
- git - 有人在签入 git ( git status ) 时遇到问题并出现这样的错误吗?
- r - 使用 if 或 ifelse
- javascript - vue 的下一页和上一页功能
- vue.js - 为 vue 中的复选框设置玩笑测试
- c# - SqliteCommand.ExecuteScalar() 返回 null(C# 5.0 和 System.Data.Sqlite)
- c++ - 在线程中退出时如何正确调用析构函数?
- .net - 如何快速更改生成和使用 NuGet 包的自定义库?
- sql-server - 使用 ruby 连接到 AIX 上的 SQL SERVER