首页 > 解决方案 > NativeScript URL Handler Plugin 无法正常工作

问题描述

我正在尝试将此插件与 Nativescript Angular 一起使用。我按照教程Nativescript Url Handler

在我的 app.component.ts 中:

ngOnInit() {
    handleOpenURL((appURL: AppURL) => {
        console.log('Got the following appURL', appURL);
        alert(appURL);
    });
}

在 android 清单中:

<activity
android:name=".activities.Activity"
android:label="@string/app_name">
<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="http"
          android:host="example.com"
        android:pathPrefix="/"/>
</intent-filter>

当我输入我的谷歌浏览器导航器:http://example.com/http://www.example.com/时,它不起作用。任何帮助,我将不胜感激。

标签: nativescriptnativescript-angulardeeplink

解决方案


我认为在 Chrome 的地址栏上点击 URL 不会打开您的应用程序。它应该是一个链接,当您单击该链接时,它会尝试打开您的应用程序。

例如,即使是 YouTube - 如果您点击 youtube.com,它仍然会在 Chrome 浏览器中打开它。如果您单击 Youtube 视频链接可能来自 Google 搜索,那么它会尝试启动该应用程序。

也不要忘记尝试干净的构建。


推荐阅读