JavaScript or HTML launching a new browser from hybrid app - javascript

So, I'm working on an app which is a web based app. The apps code base is mostly written in JavaScript and HTML. The app is also available on a native app which basically only contains a WebView displaying the HTML and JavaScript code.
My problem is that when a user is on the Android native version and launching an external link, it opens perfectly in the Android WebView but there is some cases where the launched page not is scrollable and other strange stuff.
So to solve this issue I need the native app to launch the in-build browser in the Android phone. Basically, the exact same effect that startActivity(new Intent(ACTION.VIEW,URI)) has.
The thing is that I can't modify the Android version though all the logic is written within the web app..
My question is:
Is there any way to simulate:
startActivity(new Intent(ACTION.VIEW,URI))
in JavaScript to get out of the native app and launch the browser instead?

Related

Web App runs inside Webview and installed like a native App

I created a Web App(PWA) via React and Bootstrap. It runs perfectly. I planned to create an Android and another iOS Apps that have only one page with a Webview that loads my Web App via URL and ship those Apps to the customer.
My question is that there is a better and standard way to this? I heard about Hybrid Frameworks like IONIC but as I understand, IONIC Apps, Are web Apps that run on device not loaded from a URL, Is that right?
What I want is that my changes in the server affect all users and Apps installed on their devices. Because of that, I created the PWA App, not the Native App. I searched a lot but I can't reach a final decision.
Used to be I was an Android developer and had a lot of problems with shipping the latest version to the customer, Now I want to use Web-based technologies to reach Apps that works like a website.
The issue here is: you will not be able to use the devices resources if you load the PWA in a Webview. For example push notifications will not work. A PWA can be installed onto a phone and windows as an application. This will have push notification on Android and Windows but not on Mac or iOS (Safari is the new IE). You need to go Hybrid or back to Native if you need more.
You are right with IONIC. It is a wrapper for a webapp stored on the device but it allows us to use native features (push works on both Android and iOS). But you still have the distribution issue since you need to publish to the stores every version. Not even mentioning the hoops apple gets you through when you try to publish.
The good thing with IONIC is you have a single source code for multiple platforms and you can choose the library you want to build with. It used to be Angular but now you can choose ReactJS, Vue, Angular or ES. Which makes it way friendlier.
With IONIC you could build the native features and lazy load the rest as dynamic component from a url: stackoverflow question if you do not care about backward compatibility.
I did both PWA and IONIC. Both has their pros and cons.
If I do not care about iOS and Apple I would stay with PWA otherwise IONIC.

How to open an external app in Cordova/Ionic?

I'm working on an ionic app. In my app I want to have a button that will open another app. I tested the hyper link in safari and the link opens the app correctly, but when I click the button inside my Ionic app, it's not working. The Xcode reports
Failed to load webpage with error: The URL can’t be shown
Any suggestions?
If you are trying to use externally hosted web application in your cordova application, check out cordova-hosted-webapp-plugin. The plugin enables using content hosted in a web site inside a Cordova application by providing a manifest that describes the site. Also it lets you use the features of Cordova plugins too.
But if you are trying to just invoke the external web URL from your cordova app, you can make use of cordova-InAppBrowser-Plugin which opens the web URL inside the app itself.
You can also check out cordova-themeable-browser-plugin which is almost similar to InApp browser plugin and provides more control on the browser elements available in the UI. Hope it helps

detect Android app is installed or not in device using javascript or jquery

I build a webapp and I have social links in my webapp.
I am facing an issue regarding this. If I am having facebook installed in my device then on click of the share link it should open the native app instead of opening in browser.
And incase if I doesnt have any native app installed then it should automatically redirect to browser.
Here it is the code what I have tried:
Javascript:
if(isAndroid){
fb://profile//www.facebook.com/sharer/sharer.php // to open in native browser
http://wwww.facebook.com // to open in web browser.
}
How do I handle this urls...
Please help me out.
This is not possible, for privacy reasons.
See This answer
You can make Hybrid Application.
What you just need to do is ADD WEB INTERFACE which will make call to native source code through javascript and also get return value.
So you can write native function which will return if application is installed. Once you set this interface you can use it further for open that app and passing intent and all that.
You can do it easily. Start Here:
https://developer.android.com/guide/webapps/webview.html

find out if the android browser runs in an app or for itself

I am using an hybrid android app from geyser.
I want to inform the user about the possibility to download this app, if he enters the mobile version of my website. the thing is, in the app runs a browser which views almost the same content as the mobile website.
how can I detect with JS if I am running in the App-Browser and not on the normal Browser?
I don't want to show the download Link of the App in the App.
Thanks
What you could do is have a javascript function on your page like
setAndroidApp=function(){
isAndroidApp=true;
}
and then, when you load your site through the android version (assuming you're using the Android WebView class ), you could make the function run when loading the page in the following manner
webview.loadUrl("javascript:setAndroidApp()");
in which case, you'd have isAndroidApp set to true for the rest of your code if it's seen from the android app.

Can I create HTML 5/JS application that calls windows phone 7 silverlight app

I want to build 1 UI for several phones (windows phone, Android, IPhone, etc).
My plan is to create an HTML5 UI, and use JS to invoke applications that are installed on the mobile device.
For example, I create windows phone 7 application without UI, and invoke functions of this application from the JS in the HTML 5 UI.
Same goes for android, IPhone, etc.
Is this plan feasible at all?
- How can I call windows phone 7 silverlight app/Android from JS?
Calling a native app from the browser is
possible on iOS: Opening Native App. from Safari
possible on Android: Launch custom android application from android browser
impossible on Windows Phone 7
On iOS, you can't create a web app that calls native code, period. You mention that you want the app to have no UI, so I'm assuming you want to have a web app that invokes native code which in turn causes something to happen in the web app, or even causes something to happen on the device. Won't happen. You can use the iPhone's Custom URL Scheme to LAUNCH an application with given parameters so that when it opens it immediately does something, but you will get kicked out of the browser and in to your app. And App Store Guidelines wouldn't let you make an app that has no UI. It also doesn't allow for the creation of apps that are just WebViews wrapped around HTML.
On Android, I would imagine that you could create an app that is nothing more than a WebView that loads your webapp, and in that way you would have access to the native code you wrote for the device, but I don't think that would meet up in the middle the way you want it to when it comes to having the native code manipulate your web app. Plus Android UI's are mostly XML with a little bit of backing code so at that point you may as well be making a native app.
The browser in Windows Phone 7 does not currently support HTML5, though it is expected to arrive later this year. That said, I would extremely surprised if there was ever a public API that enabled a web site to open an application on the host device and I'd be surprised if this was allowed on Android or iPhone, too.
The only application that I'm aware of that exhibits this behavior is the YouTube application. If you visit YouTube.com on the WP7 browser, then it either launches the YouTube app if you have it installed, or prompts yout to download and install it. So, the capability is there, but I doubt very strongly if Microsoft would ever open it up beyond a close partnership for specific applications.
In Windows Phone 7, you can use the WebBrowser control within an application to host/browse web content, and from the application you can call javascript methods exposed by that page as described by Shawn Wildermuth in his Navigating with the WebBrowser Control on WP7 post.

Categories