【问题标题】:How to add universal links with content inside Cordova app如何在 Cordova 应用程序中添加带有内容的通用链接
【发布时间】:2021-06-12 09:41:02
【问题描述】:

我是在 Android 中制作的。

  1. 在 Android Studio 的 MainActivity.java 中添加新的活动

    // 在 config.xml 中设置 loadUrl(launchUrl);

改成

 // Set by <content src="index.html" /> in config.xml
        loadUrl("file:///android_asset/www/Any_Page.html);
  1. 以任意名称保存新活动

  2. 在上方菜单的 Android Studio 中 - 工具 - 应用程序链接辅助 - 打开 url 映射编辑器添加带有新活动的 URL 映射路径 所以不需要任何插件。 现在在应用中链接打开的内容。

但我无法在 Xcode for iOS 应用程序中创建相同的链接。 在 Appdelegate.m 中,我可以更改起始页**

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    self.viewController = [[MainViewController alloc] init];
    self.viewController.startPage = @«My_page.html; // relative path works
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

但我需要获取 url 路径以在 Cordova 中选择我的起始页。 第二种方式 - 从 index.html 中的 JavaScript 更改起始页

<script>
window.location.href = “MyPage.html”;
</script>

但我需要打开我的应用程序的 url 路径。 我网站上的 URL 路径与应用中的相同。

/content/page1.html
/content/page2.html

等等... 当我的应用从链接打开时我需要 - 在应用中显示相同的内容。

【问题讨论】:

    标签: android ios cordova deep-linking ios-universal-links


    【解决方案1】:

    Cordova 中有一个用于通用链接的未维护插件。

    不久前我创建了一个带有一些修复的分支:https://github.com/GEDYSIntraWare/cordova-universal-links-plugin

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2021-12-29
      • 2023-03-22
      • 1970-01-01
      • 2016-09-04
      • 2013-04-30
      • 2011-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多