Clicking a mailto: link will open my default mail client. In a similar manner, I would like to launch an Electron app with my-app:. What is the best way to achieve this and gracefully fallback to a standard http link if the app isn't installed?
Furthermore, I would also like to be able to pass through some extra details my-app:foo/bar. How would this be intercepted inside of Electron when it launches?
I have read some docs on what I think might be relevant stuff: http://electron.atom.io/docs/v0.36.0/api/protocol/ however as a frontend dev there's some gaps in my understanding of how the overarching process works. Any help much appreciated!
Electron has evolved quite a bit since this question was first posted.
You no longer have to dive quite as deep and can skip the Electron protocol API. Instead, use the app.setAsDefaultProtocolClient(protocol[, path, args]) interface and its siblings app.removeAsDefaultProtocolClient(protocol[, path, args]) and app.isDefaultProtocolClient(protocol[, path, args]).
These enable you to register a protocol identifier your-protocol:// and receive arguments:
The whole link, including protocol, will be passed to your application
as a parameter. Electron API docs
I'm not sure if it is possible to do what you want to do. Depending on whether you want to launch your Electron app from an actual browser window or simply from another Electron instance.
I found this other Stack Overflow post link that shows a workaround (though I'm afraid it won't graciously default to anything) and explains how it could be dangerous to launch programs directly from the browser.
If you want to launch your Electron app from another Electron app however you might want to check this out link.
Related
I have a problem, where I need to route HTTP requests from the IOS WebView through a HTTP proxy.
The intention is to route it through a HTTP proxy running Privoxy, so all tracking scripts and ads are removed. I want to provide a free app on the appstore, where people can browse without having to view ads and being tracked.
It seems that it is possible somehow with the UIWebView, but since it has become deprecated, I could imagine that other issues would start popping op, if I used that... I have not been able to find any sources officially nor unofficially, if the newer WKWebView can do this. If any of you know this and would share your knowledge on it, it would be much appreciated.
I have so far developed my full app in React Native, which seems to have no way of doing this at all, so before redeveloping everything in Swift, I want to make a bit more sure that it is actually possible there and thus meaningful to change...
Not possible with react native webview:
https://github.com/react-native-community/react-native-webview/issues/115
I have searched here for answers but I only seen few links to Microsoft c++ codes but none for Delphi so just wondering if anyone has a working Delphi example on how to launch programs from URI and get data from it to maybe connect to a socket or load a resource within my program?
Thanks
am basically looking for away to launch my program from a web address URI c++ code am none the wiser what to post as I can not understand that to save my life
and am sorry about not being more clear but I do find spelling things little hard and putting across what I would like I like to use voice mostly ha
You must register URI scheme for your application. For example, you may create "myapp" scheme. After this, if you open url like "myapp:do_something&close" Windows will launch your application with single parameter equal to URL.
"C:\program file\Soft\MyApplication.exe" "myapp:do_something&close"
In your application, you can read first parameter (ParamStr(1)), parse it and decide what to do.
"do_something&close" in my example, may be any kind of data. But if you want to open your application from web site, you may use HTTP URL format, like "myapp:\cleandisk?drive=C&askuser=yes"
See more info what you must write into Windows Registry in order to register your own URI scheme.
My app relies on an external service that might change its output any time without warning, so I would need a completly new function to parse it. Is there anyway to update my service parser without having to re-submit the whole app for review? Otherwise part of my app would be broken during the time to develop and review the new parser. I was told I cannot use bundles for this, so I really am clueless how to solve this problem.
You can't solve that problem completely on the client side.
Depending on the output format of the external service, and the methods you use to parse its output, you might have the option to store a file in a server that contains information about the current output format of the external service. Then your app can use the meta-data in that file to determine how to do the parsing.
You can also develop a simple web service that wraps the external service. Then your app can use the web service instead of the original service, and whenever the output of the original service is changed, you can quickly update your web service to make your app continue functioning properly.
I'm trying to build a "native web app" using HTML + JS on iOS. As you may know you can add such an application to the homescreen and it will more or less look just like a normal native app.
However if I quit such an app and reopen it again it reloads the whole page again. This also happens when switching to such an application from another over the multitasking bar.
Is this expected behaviour or is there a way to stop the device from doing this?
As an example you can add the jqTouch-Demos from here to your homescreen and test it: http://jqtouch.com/preview/demos/main/
You could save the state of your app in localStorage. On restart, check to see if the state is running, then restore the app to where it last was.
Same problem here.
Anyway, if you don't want to reinvent the wheel you can use a tool like PhoneGap (http://www.phonegap.com/). Native web application wrapper with built in access to a number of native features.
Also, you store the application locally (fast, secure) and you can of course charge for it ;)
It's under BSD or MIT license.
Update: as this answer is receiving downvotes, I added this explanation.
Your problem might not be the actual reload, but the fact that Mobile Safari treats your user's cache and cookies differently when your web app is opened through the browser, than when it's 'installed' as a web app to the home screen. Although the solutions proposed here that use localStorage will work, they're a lot of work for client-side logic that can be avoided if your server is already responsible for persisting the session state of your user. The 30-second solution is to simply explicitly set the session cookie to have a longer lifetime.
This allows you to keep the state intact even between device reboots, so even though it doesn't technically stop the web app from being reloaded when launched from the home screen, it is an easy way to restore the state for the user without him/her noticing the reload - which in many cases I suspect is the real problem.
For a more elaborate discussion of this strategy and code examples, take a look at these questions and my answers there:
Maintain PHP Session in web app on iPhone
iPhone "Bookmark to Homescreen" removes cookies and session?
You might want to look at using cache-manifest to prevent it loading the files.
Matt Might has a good writeup here:
http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/
Basically you change the html tag to this
<html manifest="cache.manifest">
and write a cache.manifest file on the server which specifies which files should be kept in the device cache and which should be reloaded dynamically from the network.
CACHE MANIFEST
local1.file
local2.file
NETWORK:
network1.php
network2.cgi
You also need to make sure your web server serves up .manifest files with the MIME type text/manifest, or else this won't work. If you're using apache, put the following in your .htaccess file:
AddType text/cache-manifest .manifest
I'm writing an application, which becomes "useful" once user is browsing certain url.
I want to add feature to my application, that it will be automatically launched once user browses this url, I was thinking of writing some sort of watchdog to trigger it.
My question is, whether there is a generic way to get notified when user browses to urls, I want to support at least IE and FireFox, chrome and safari is nice to have.
I read about DDE and WWW_RegisterURLEcho, but from what I understand it's not supported by FireFox, and also little sample I wrote didn't work with IE as well.
Thank you in advance
some more questions **
Do Url Monikers and Asynchronous Pluggable Protocols help me here ? Is it supported by FireFox ?
If you have control over the website, you could have it write a cookie to the computer. Then have your application monitor for that cookie.
You can implement this in many ways and at many different layers.
At the highest level, you could implement a browser plugin. There is no cross-browser solution at this layer that will let you write the code once and work for every browser. On the easy end of the spectrum, Firefox, you could implement it entirely as a Javascript + XUL plugin and use built-in XPCom interfaces (nsIProcess) for launching your helper process. For IE you would need to write a COM, C++ and win32 BHO that handles DWebBrowserEvents2::BeforeNavigate2. This is the hardest thing to do. There are mechanisms for Safari, Chrome and other webbrowsers that you could use to achieve this same behavior, with varying degrees of difficulty.
At the next level you could implement an HTTP proxy, similar to Fiddler2, that redirects all HTTP traffic through your local proxy first. Each browser has a different way of configuring its proxy settings, but they're all basically registry settings or config files.
At the most basic level you could just snif all IP traffic going out of the machine, similar to the way Wireshark does it, and just look for http requests to your URL. This is probably more difficult to code, but would work for all browsers without any special per-browser configuration stuff going on. You may need to write a driver. I dunno, I've never done work at this level in the stack.