Cordova Custom-URL-scheme plugin not working - ios

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

Related

Cordova white screen of death iOS - browserify, react, cordova

I have a strange situation with a project for iOS.
Its created using browserify and React for Cordova and aimed at iOS.
We have built the project for iOS using Cordova commands without any issues. It runs with no xcode errors or Javascript errors either however none of the JS ui appears on screen. We just get a blank white screen with the system bar at the top. See attached screen shot.
So far we have found out that if you add HTML to the index.html in WWW folder it prints that fine so I assume its the JS.
When we run in a browser it works as well as building for Android.
We have no problems with anything other than iOS (simulator and device build).
hopefully someone can help me out here because I'm stumped. Please let me know what files you need to look at and I'll make them available.
Thanks in advance.
IMAGES
The error screen: http://www.voidapplications.co.uk/errorScreen.png
What we expect to be shown: http://www.voidapplications.co.uk/whatWeExpect.png
If you are using internationalization component that's because you need to use the Intl polyfill:
Intl.js and FT Polyfill Service
Intl.js polyfill was recently added to the Polyfill service, which is developed and maintained by a community of contributors led by a team at the Financial Times. It is available thru cdn.polyfill.io domain, which routes traffic through Fastly, which makes it available with global high availability and superb performance no matter where your users are.
To use the Intl polyfill thru the Polyfill service just add one script tag in your page before you load or parse your own JavaScript:
<script src="https://cdn.polyfill.io/v1/polyfill.min.jsfeatures=Intl.~locale.en"></script>
When specifying the features to use thru the polyfill service, you have to specify what locale, or locales to load along with the Intl polyfill for the page to function, in the example above we are specifying Intl.~locale.en, which means only en, but you could do something like this:
<script src="https://cdn.polyfill.io/v1/polyfill.min.js?features=Intl.~locale.fr,Intl.~locale.pt"></script>
note: the example above will load the polyfill with two locale data set, fr and pt.
This is by far the best option to use the Intl polyfill since it will only load the polyfill code and the corresponding locale data when it is really needed (e.g.: safari will get the code and patch the runtime while chrome will get an empty script tag).
source & other ways to include Intl polyfill: https://github.com/andyearnshaw/Intl.js#getting-started
You can debug the UIWebView in the simulator with Safari http://moduscreate.com/enable-remote-web-inspector-in-ios-6/. You'll probably see a big error message in the console, if not you will have access to the debugger so you can step through and sort it out.
I have had this issue in the past, it turned out to be unsupported javascript features. for example, setting default parameters in the function. I.e:
function test( myvalue=0 ) { /* ... */ };
I had to initialise the value inside the function instead. You could also try removing any ecma script 2016 features you may have implemented.
Trouble shooting this type of issue was painful. I created a minimal version of the smallest part of my product compiled and ran it on ios emulator, added another chunk of the product, rinse and repeat.
Im sure there's a better way to detect these issues, but I do not know it.

how to get webview to work in dart

I want to use the webview tag in a chrome packaged app written in Dart,
I try to get the browser example inside the webview package to work
https://github.com/HannesRammer/webview
but when I set the webview attribute 'src', or call a function like 'back' using the jsinterop, it tells me unknown method back ... as far as I can see the package uses the correct jsinterop calls
maybe webview is not proper supported by jsObject, or what am I missing out ??
thanks :)
Make sure that you are running it as a Chrome App (right-click on the manifest.json in the Dart Editor and select "run as Chrome App"). The errors you describe sound like what you would see in a web app context, where the Chrome APIs are not available... also check that you have the webview permission in the manifest.json file.

Web service call missing field value xamarin IOS

I'm having a web reference which is being used by both a Xamarin IOS application, Xamaring Android application, and a Windows Store application.
And this all worked very well, until I updated Xamarin.
Now, there is a field that But it works fine for the Android and Windows applications.
I have tried to update the web reference multiple times, with no luck. I have also tried to debug the web service locally, to see if it returns the same , which it does.
When I receive it in my Windows Store app., it looks like this:
And in my IOS app., it looks like this:
It is always the StructureId that is never set, for some reason. And it was not like that before I updated Xamarin.
Anyone who knows what I am doing wrong, or have stumbled onto the same kind of problem ?
That looks like the linker removed unused members. Defaults have not changed (it's not related to your update) but you should check that your application is being built with Link SDK (and not Link all).
If you want a smaller executable and set Link all to achieve this then you'll need to add [Preserve] attributes on the structure you're serializing (e.g. used in web services).
I was able to make it work. I am not sure if it cached anything, or what, but it helped to add some "noise" on the webservice call.
I just added DateTime.Now.Ticks to my webservice URL in Reference.cs, so it would always be a new URL call:
this.Url = "http://somewebsitename.com/ReportService/ReportService.asmx?v=" + DateTime.Now.Ticks;

Launch intellij via URL

Would it be possible to register some protocol
and then launch IntelliJ via an URL. I am
thinking of submitting the URL via Desktop.browse()
from within a JVM.
My idea is that the URL would consists of
a file name parameter and a line number parameter.
And IntelliJ would then open this file name and
scroll to the given line number. Here is an
example:
intellij:/mypath/myfile#99
Has this already been done?
Bye
P.S.:
java.awt.Desktop Class
http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html
Check IDEA-65879 for existing workarounds or vote for the issue so that it's available out of the box in the future versions.
One of the suggested solutions is the Remote Call plug-in.
You could use IntelliJ Platform REST API.
Example to check: http://localhost:63342/api/about
Use Postman to send these requests.
For me, it works on IntelliJ Idea but unfortunately, on Android Studio it doesn't work.
Asked this question about it.

opening-local-html-file-with-android-browser in android 3.x

with android 2.x i could use the solution
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity")
resolved in the post:
opening local html file with Android Browser
but with android 3.2 i have this error:
Unable to find explicit activity class
(com.android.browser/com.android.browser.BrowserActivity);
have you declared this activity in your AndroidManifest.xml?
I think that the class com.android.browser.BrowserActivity doesn't exist in Android 3.x
Any solution?
Not a satisfying solution, but in a demo application I alternatively used the following code:
String url = "content://com.android.htmlfileprovider/sdcard/mydir/myfile.html";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "text/html");
startActivity(intent);
Usually at least one of the two works.
https://github.com/nicolas-raoul/OxygenGuide-Android/blob/master/src/org/github/OxygenGuide/MainActivity.java#L69
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity")
Will open whatever app has the packagename "com.android.browser". The issue with using this is that over various versions of android and various manufacturers, the default browser changes. For example Nexus devices tend to come pre-installed with the chrome app, which has a different package name.
Unable to find explicit activity class
(com.android.browser/com.android.browser.BrowserActivity);
have you declared this activity in your AndroidManifest.xml?
The error you have copied explains that there is no application with that package name browserIntent.setClassName() is used to open a specific app explicitly which means it shouldn't provide a prompt asking which browser you would like to use.
If this is what you want to avoid (pop up), then you can check what browsers are on the device and possibly suggest downloading it before making links clickable.
you also could use the code from the other suggestion.
String url = "content://com.android.htmlfileprovider/sdcard/mydir/myfile.html";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "text/html");
startActivity(intent);
This specifies that you want to open an activity that can handle the "text/html" type data. By viewing it. This would provide you with a list of applications (different installed browsers) for you to select.
Uri uri = Uri.parse(url);
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setDataAndType(uri, "text/html");
browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(browserIntent);

Resources