I am trying to use electron's webFrame.executeJavaScriptInIsolatedWorld method but I get an error saying its not a function. I am trying to use this in a preload script of a webview.
import { webFrame } from 'electron'
webframe.executeJavaScriptInIsolatedWorld(123 , [{code: 'alert("hello")'}])
When I console log the webframe object and check its prototypes then
executeJavaScriptInIsolatedWorld is not present there so I understand why I am getting the error. But the electron docs (here) mentions that this method is available. I am a little confused by this. Am I using it in the wrong location? Can this not be used inside a webview's preload?
You are reading docs for 2.0.2 version of electron. 1.7.11 you use https://github.com/electron/electron/blob/v1.7.11/docs/api/web-frame.md doesn't have those interface.
Related
I'm building an electron app using capacitor and need to modify the content-security-policy headers. I've tried using a <meta> tag but electron appears to be adding CSP headers which are overriding the values.
There is a function called setupContentSecurityPolicy() in electron/src/setup.ts which appears to do what I want. However, I can't seem to find the correct hook to call it.
When I import this and call it from electron/src/preload.ts I get an error suggesting that the global variable electron.app is undefined. I have made no changes to the electron source files apart from adding this import and function call to electron/src/preload.ts.
I'm new to capacitor and to electron and can't seem to find any documentation on this. Any advice appreciated!
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
I try to use JavaScript library visjs.org in Dart. I prepared ‘adapter’ code according examples on Dart site pub.dartlang.org/packages/js and github.com/google/chartjs.dart/blob/master/lib/chartjs.dart.
Also according basic use case example from http://visjs.org I prepare client dart code.
While code compiles without any errors and warnings nothing happens in browser, expected to see graph-tree.
What I did wrong or miss to do?
https://gist.github.com/EdSv/e274a4d12ad3491c383fb4fe76ee671e
The attribute #anonymous is meant to be used when the object you're describing doesn't actually exist in the JS library you're binding, and is only used as a plain old data object. By adding it to all of your objects, my guess is that dart is never attempting to create anything from the visjs library.
Try removing the #anonymous from your Network class and see if that has an effect. You will likely also need to make these abstract classes as well.
I want to print (on printer, not console) from a dart chrome app.
It is possible to print from chrome apps. Here is official sample.
This works properly for javascript apps, however I cannot do similar in dart.
Here's what I tried:
import 'dart:html';
import 'package:chrome/chrome_app.dart' as chrome;
void main() {
chrome.app.window.current().print();
}
Thanks in advance.
Update:
There seems to be no print() method in AppWindow object.
The question is how can I in dart access print() method? I mean the one that is available in javascript in window object. Not in regular dart runtime environment but when code is executed as chrome app written in dart.
Update2:
I posted the answer. The remaining mystery is how to get the DOM Window object from AppWindow object?
The answer seems to easier than I thought...
window.print()
does the job as described in documentation.
How would I expose an Objective-C method within JavaScript when using the iPhone SDK when using the UIWebView?
Any help would be appreciated!
The best way to do this would be through a custom link, and then use the UIWebView delegate method -webView:shouldStartLoadWithRequest:navigationType: to trap requests. When you see a request come through with your link in it, you know your action has been triggered.
There is an example application in the QuickConnectiPhone framework that shows you how to do this.
QuickConnectiPhone also gives you a JavaScript function called 'makeCall'. You pass it a command and an array of parameters and it will pass them to the Objective-C side of your app for handling. You can then make your function call.
You can find it here on Sourceforge.
To see an example of this check out the PhoneGap source code from Github:
http://github.com/sintaxi/phonegap/tree/master/iphone/Classes/GlassAppDelegate.m