简体   繁体   中英

Cordova Custom-URL-scheme plugin not working

The only plugin I can find is this one https://github.com/EddyVerbruggen/Custom-URL-scheme

I try to install it and check its iOS implementation, it is empty inside plugins/cordova-plugin-customurlscheme/src/ (no ios folder found, only android and window ). I check the plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js , the content is:

"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.
*/

It doesn't make sense, based on my understanding, it should implement func application(_application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool in the AppDelegate , but it is empty. In this case, how come overwrite handleOpenURL in the JS will work?

I really couldn't find others, can anyone advise similar workable plugin? My scenario is, when A app call B app, my B app is a cordova app, and I need a listener/callback to capture the url content.

Updated:

added in MAF tag, as the issue was caused by Oracle MAF framework, didn't expect that, thought the issue coming from Cordova.

It should not implement something in iOS. Custom URL scheme only updates Info.plist in iOS. So, it's fine. It REGISTERS custom URL schemes.

To handle the URL them you need to right your own code. How plugin will know what you need when custom URL is opened?

Alright, I know why there is no such implementation in https://github.com/EddyVerbruggen/Custom-URL-scheme

That is because in cordova-ios CDVHandleOpenURL.m , it already contained such implementation, it will consume the notification which is posted by the CDVAppDelegate.m , and in the CDVHandleOpenURL.m , it will execute handleOpenURL in the WebView JavaScript namespace.

The reason why my apps is not working, it is because Cordova was wrapped in the Oracle MAF framework, and it overwrite the custom URL mechanism provided by Cordova, which is not what I expected, so I forgot to mention MAF in my original question, I will add in related information.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM