【问题标题】:Cordova Custom-URL-scheme plugin not workingCordova 自定义 URL 方案插件不起作用
【发布时间】:2021-01-09 13:18:18
【问题描述】:

我能找到的唯一插件就是这个https://github.com/EddyVerbruggen/Custom-URL-scheme

我尝试安装它并检查它的 iOS 实现,它在 plugins/cordova-plugin-customurlscheme/src/ 内是空的(没有找到 ios 文件夹,只有 androidwindow)。我查了plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js,内容是:

"use strict";

/*
 Q: Why an empty file?
 A: iOS doesn't need plumbing to get the plugin to work, so..
    - Including no file would mean the import in index.html would differ per platform.
    - Also, using one version and adding a userAgent check for Android feels wrong.
    - And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here.
*/

没有意义,根据我的理解,应该在AppDelegate中实现func application(_application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool,但是它是空的。这种情况下,怎么覆盖handleOpenURL中的JS会起作用呢?

我真的找不到其他人,谁能推荐类似的可行插件?我的场景是,当A应用调用B应用时,我的B应用是cordova应用,我需要一个监听器/回调来捕获url内容。

更新:

MAF标签中添加,因为问题是由Oracle MAF框架引起的,没想到,以为问题来自Cordova。

【问题讨论】:

    标签: ios cordova cordova-plugins oracle-maf


    【解决方案1】:

    它不应该在 iOS 中实现某些东西。自定义 URL 方案仅在 iOS 中更新 Info.plist。所以,没关系。它注册自定义 URL 方案。

    要处理 URL,您需要修改自己的代码。打开自定义 URL 时插件如何知道您需要什么?

    【讨论】:

      【解决方案2】:

      好的,我知道为什么https://github.com/EddyVerbruggen/Custom-URL-scheme没有这样的实现

      那是因为在cordova-iosCDVHandleOpenURL.m中已经包含了这样的实现,它会消费CDVAppDelegate.m发布的通知,而在CDVHandleOpenURL.m中,它会在WebView中执行handleOpenURL JavaScript 命名空间。

      我的应用程序不工作的原因,是因为 Cordova 被包裹在 Oracle MAF 框架中,它覆盖了 Cordova 提供的自定义 URL 机制,这不是我所期望的,所以我忘记在我的原始问题,我将添加相关信息。

      参考: https://docs.oracle.com/middleware/maf210/mobile/develop-maf/maf-ui-remote-url.htm#ADFMF24147

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-29
        • 2012-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-17
        • 1970-01-01
        相关资源
        最近更新 更多