Destroy React Native Webview - webview

I have a React Native application that uses a WebView to display a Highcharts chart. It was working for a while but out of nowhere it just stopped loading in Android. The only fix I could find was to disable Chrome and re-enable it. Which makes me believe there is something going on Chrome on my phone that's making it break. I see in the Android developer docs, the WebView has a destroy() function.
Is there a way I can call this function from my React Native app?

MMM the purpose of the question is unclear.
You don't want to display the webview ? don't display it , remove it from the render function.
You want to display the webview ? display it.
You want to have conditional rendering ? have it, it will destroy the webview or create a new one. There is a lot of posts of how to have conditional renderind in google.
My suggestion would be... update chrome. If it's already updated, go back to previous versions. If you have android 7+ i think you can change the webview provider in the developer options, if you can, change it to android system webview (you will need to manually install it from the play store). Don't use a native solution for personal device problems.

Related

How to view javascript errors in ios simulator launced by phonegap?

I can't seem to find an answer to this seemingly simple question. I have an app that i've built using the command line phonegap tools and when i start this app it opens up. i am using something called ios_sim (https://github.com/phonegap/ios-sim) which launches the app in the simulator and does not launch xCode (i don't quite understand why this is a feature, it seems like xCode has some useful tools)
Anyhow, my app is not functioning the same way that it does in the browser and i need to debug it. I have also already installed Charles to inspect the requests and i can verify that the correct data is coming from my API so my assumption is that there is some sort of javascript error in rendering the page (the page is partially rendered btw).
All i want to do is view the javascript errors. the same way that you would in the console if you were looking at a web page.
how do you do that?
You have to use Safari Remote Debugging with Web Inspector. See in the relating cordova docs how to do that!

qooxdoo mobile - click handlers not firing in ios

I have a mobile app built using phonegap +qx mobile 3.5.
I have a page implemented using qooxdoo mobile which has a header implemented using qooxdoo controls. The content section of the page is loading from an external system using a ajax call which returns a string(html+css). The html has built in click handlers which are not firing on ios. The html works fine when loaded directly without qx.
This is an existing app in android and seems to work fine there. Can someone help me get this working on ios?
EDIT : I am using native scroll and not the custom scroll plugin.
I believe this problem is caused by the used scrolling method.
If you just remove the macro "qx.mobile.nativescroll" out of your config.json,
qx.Mobile detects itself whether to use NativeScroll or iScroll.
In version 3.5 that means, Windows Phone 8 and iOS7 are using the native scrolling.
Do not forget to rebuild after removal.

Phonegap/Cordova 2.9 iOS In-App Browser not opening when Google Admob plugins are included

I'm developing a phonegap/cordova 2.9 iOS App with jQuerymobile which some links need to open a url with InAppBrowser. Also I've integrated Google Admob. Navigation is basic single page template with some different html pages.
When App is loaded, if I don't go to other sections of the app, when press buttons with In-App Browser URLS, In-App Browser opens. But if I go to other sections of the app and go again to index.html, In-App Browser fails and not working.
Different sections of the App are linked with target="_blank". If I link sections without target="_blank", all works correctly, but I need use target="_blank" to go back to index.html and reload XML data.
I'm searching any solution some days ago but I haven't find anything. Only one similar detailed in this post, but without solution:
http://iphonedevsdk.com/forum/iphone-sdk-development/115057-inappbrowser-is-not-opening.html
Another thing I've tried is install Childbrowser Plugin from https://build.phonegap.com/plugins/2 and use it instead of In-App Browser, but I canĀ“t make it work.
Can anybody Help me?. Thank you very much.
You may have moved on from this, but my scenario was that I was using Cordova 2.9.1 with jquery mobile. At certain points in the user experience I also go back to index.html. This worked fine unless I opened InAppBrowser at any point. InAppBrowser worked, but the next time I went back to a refresh of index.html, all plugins including InAppBrowser would not execute.
My fix was to make a change to CDVInAppBrowser.m as follows:
Instead of:
BOOL isPDF = [#"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:#"document.body==null"]];
if (isPDF) {
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
}
[self.navigationDelegate webViewDidFinishLoad:theWebView];
I took out the isPDF logic and just made sure that it always updated to the previous UserAgent. I was left with just..
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
[self.navigationDelegate webViewDidFinishLoad:theWebView];
Hope this helps someone who may have been in a similar scenerio of InAppBrowser breaking jquery-mobile or similar frameworks when cordova.js was reloaded again.

Cordova trying to dial telephone number

I am trying to dial a phone number in iOS, however I only have the simulator and an iPod Touch to test on.
The code uses something along the lines of:
window.location.href = 'tel:01234567890';
Working fine with Android, but in iOS it dies with:
Failed to load webpage with error: The URL can't be shown
Now, I do realise this has been asked before, but the general consensus from some time ago was "It doesn't work, you'll need to use a plugin". There haven't been many questions on this for some time though, and what questions there are seem to suggest it works when doing it programmatically (as above with window.location.href). I have tried the iOS PhoneDialer and the newer version of the same plugin, but both have errors in XCode (ARC forbids explicit message send of 'release') - a bit of faffing and I can get this running, but then PhoneGap doesn't find the plugin - it really feels like I'm hitting a brick wall with this method, and I can't believe something as simple as this requires something so over the top.
I know you cannot auto-dial/auto-call a number for security reasons, but all I need to do is open the dialer with number pre-populated, which is surely no different to a mailto:info#example.com link opening your email client with the sender pre-populated?
So, my questions are:
Has this changed with a recent update to PhoneGap, iOS or XCode?
Or, is it a case that I cannot do this on an iPod or Simulator, and it will work fine on an iPhone?
How can I fix it? :)
You didn't specify which version of Cordova you are using so I'm going to assume version > 3.
Make sure that InAppBrowser, a plugin since version 3, is installed and then open the link by calling it through Javascript like this:
window.open('tel:12345678', '_system')
_system will open it with the systems own browser which in turn will open the call dialog, if you use it against http://maps.apple.com/ it will open in the maps app and similar for other apps which opens for special urls.
Remarks:
As described in the docs of the InAppBrowser plugin the window.open function won't be set automatically. You have to do it your self: window.open = cordova.InAppBrowser.open;. Instead you can directly use cordova.InAppBrowser.open('tel:12345678', '_system');
Make sure your number doesn't have any blankspaces in it (the +
prefix is okay). For example you could use a function like the following,
assuming num is a string.
Function:
function placeCall(num) {
if (window.cordova) {
cordova.InAppBrowser.open('tel:' + num.replace(/\s/g,''), '_system');
}
}
Below Code works perfectly fine for iphone:-
window.open('tel:123456', '_system');
Simulator doesn't support dialer. No need to waste time.
Make sure that the phone number in your href also doesn't have any formatting in it, as on iOS it causes the link not to work in a PhoneGap App. So for example, use tel:0390005555, and not tel:(03) 9000 5555.
I don't believe this is a Cordova issue. I know in native iOS you cannot bring up the dialer on the simulator or on an iPod touch. You will need to test this on an actual iPhone.
I know this is a late answer time.
Try by adding // to the url. Like this tel://xxxxxxxxx and see if it works.
Worked for me in IOS 8.4, iPhone 6, 6+ as of today.

How to create a HTML link to a build.phonegap app?

I have run into several problems with iOS development through phonegap recently, and unusually people around here have been unable to discuss these issues and even together we have (for the first time I have ever seen) not had a single comment or answer for these topics...
See https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app and iOS broswer data -> Cache & Cookie for Phonegap App / Session?...
However, I have found "solutions" to get around these, but its by no means answers to the issues in question which are still outstanding... just simply doing it a completely different way.
However, despite loosing web-view in phonegap, in an attempt to get around https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app I now have some issue that are outstanding...
I need to be able to navigate back to my App from the web-system !!!
However, I have no idea how. I have read info on creating URL Schema, but I am not sure if this is even possible through build.phonegap at all... and it seems faily complicated. Does anybody know of a way for iOS safari to do one of two things
Either
Open the app that is running in the background
or
close the current browser tab and navigate back to the app in the background.
The closing tab idea would be good, but not essential
Look forward to everyone thoughts and opinions on this one...
Henry
You can create an url scheme for any application you make yourself.
See tutorial here
It's not as terribly complicated as one would think, and the required objective-c code is minimal.
Once you have done this, you can use your own url scheme to launch your phonegap application from safari with a hyperlink.
This would not close the tab (you could do this with javascript if you wanted to)
but does put safari in the background, and opens your phonegap app.
(whether it is already running in the background or not)
It is even possible to pass data to the app using your url scheme.
It is not currently possible using PhoneGap Build in 2.2 and previous. Potentially a feature top be released in newer versions of Cordova/Phonegap

Resources