So I have a BarcodeScanner implemented in my iOS app and it works fine for when a user clicks on a field in the app, it opens the scanner and fills out the data. However, there is another part of the app with a WebView and in that WebView are fields that I would also like to trigger the BarcodeScanner in my app to open up and fill those out. I'm not sure where to get started with this, since I don't really do web development and I'm guessing it requires coding there? Any help would be appreciated. Thanks!
Create a class which implements the BarcodeScanner (assuming you are either using a pod or an import in swift). Once you create that, you can connect it to how many pages/buttons you'd like. Initialise the web view, add a button, and choose your custom BarcodeScanner class to direct to the scanner in the app.
func stopLoading() {
mWebView.removeFromSuperview()
self.moveToVC()
}
func moveToVC() {
print("Write code where you want to go in app")
// Note: [you use push or present here]
let vc =
self.storyboard?.instantiateViewController(withIdentifier:
"storyboardID") as! YourViewControllerName
self.navigationController?.pushViewController(vc, animated: true)
}
Related
I am trying to use a PWA I develop with HTML and JavaScript to process data and send it back to the Android app.
The Android should open the PWA after the user clicks a button for example, I already did this by starting an activity with an intent using the page URL:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://examplePWA.com/"));
Log.d(TAG, "onClick() called with: view = [" + browserIntent.getDataString() + "]");
startActivity(browserIntent);
What I want now is to get a response intent from the PWA to a startActivityForResult (browserIntent, 123);
sent from Android for example.
How can I do this from the PWA side, is it possible to send an Android Intent from a PWA using JavaScript or any other way?
If I got you right, for the purpose of starting an activity from within the javascript env, you could employ the #JavascriptInterface which will allow you to invoke Java methods inside your javascript code (if you use WebView).
class WebBridge {
#JavascriptInterface
public void openBrowser(String href) {
// .. start your activity here
}
}
// Somewhere where you initialize your WebView
webView.addJavascriptInterface(new WebBridge(), "AndroidWebBridge");
// Inside your javascript app code
window.AndroidWebBridge.openBrowser("https://google.com");
The code below illustrates the overall concept, not a copy-paste solution. Hope that helps your.
I have an android app with a WebView, it is written in Java Script and Angular JS code to access the Camera , I just load the URL in web view and had given camera access permission and read and write external storage permission, still it is not able to access the camera , I had browsed for this problem ,but didn't find the exact solution.
I just want to open the camera , when user click on take photo on his profile page which was written in java script code , don't know when this will happen because I have base URL only which was loaded in web view.
How to let the user open the camera in this application? And also it should support from Kitkat onward, Can any one help me to figure out this?
Use openChooser method when implement UIClient
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.addCategory(Intent.ACTION_CAMERA_BUTTON);
i.setType("*/*");
startActivityForResult(Intent.createChooser(i,"File Chooser"), 111);
}
Hi in my application i am loading local html pages in my webview ,this html pages will load based on the locale or language selected , these pages also have values which i pass dynamically using JS ,but when i am changing the language, i am unable to change the dynamical values so i thought to restart the application if there is configuration change no matter in what screen i am. The application should start from scratch that is splash screen .How can i achieve this. Go code to restart the app, but is it correct way
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(
getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
MainActivity.this.finish();
this is the which works for me. i have a splashscreen before MainActivity and is works fine..
I am currently working on a hyrbid mobile app for windows phone 8.0 and windows phone 8.1 using the cordova framework. There is a scenario where I need to use the in-app browser to launch a login page.
I used the following javascript code .
var authWindow = window.open('http://www.mylogin.com', 'mywindow', 'location=yes,toolbar=yes,clearsessioncache=yes');
Although the window opens fine I am getting null as the reference to the window object here. I need the reference to perform other actions on the opened window.
On further research I found that issue exists in desktop IE11 also and we have to disable the protected mode. Once I did it and ran the code on desktop IE11 it worked fine.
I am not sure how to achieve the same in my scenario. Is there any setting I need to change on the browser control? How do you resolve this?
Open external pages on Windows Phone as a Javascript Mobile App is a real problem. On Android and IOS you just use "windows.open" and you are good to go. But on WP, we will need to create a C# plugin.
On my app, I did the following:
1 - You will need a javascript function that calls the plugin.
Javascript call
function openExternalURL(theURL) {
cordova.exec(function () { }, function () { }, "yourApp.main.plugins.YourPluginClass", "openURLWithNative", [theURL);
};
2 - Now you need to implement a C# class that calls Windows Phone browser with the correct URL. For it, you should create a .cs file (in the example its name is YourPluginClass.cs):
YourPluginClass.cs (C#)
namespace yourApp.main.plugins
{
class YourPluginClass : BaseCommand
{
public void openURLWithNative(string uri)
{
WebBrowserTask task = new WebBrowserTask();
string optVal = JsonHelper.Deserialize<string[]>(uri)[0];
task.Uri = new Uri(optVal);
task.Show();
}
}
}
This way, you can open any external URL on Windows Phone like Android and IOS.
Hope it helps. Best Regards!
There is a few good workaroungs that worked for me in :
Do a window.open("about:blank", "newPage"); before the AJAX call and then after the call add the URL to the opened window by calling window.open("http://google.com", "newPage");.
I want Write a web page for service to Android device.
before every thing i want to check is there any javasscriptinterface object used in the WebView or not... if there is any detect that.
i am writing my new Exclusive security method for develop safe page.
All help appreciated.
The JavaScript Interface is added by the WebView as an Object of the window component.
So you can test JavaScript presence by doing :
if (window.MyJavascriptInterface)
{
// Interface present
}
else
{
// No Interface
}
Here is the Android documentation