I am using two plugins (cordova-plugin-auth-dialog & cordova-inappbrowser) to realize the login process for my cordova ios app.
The login itself is working really fine on the iPhone, but on the iPad it is causing a long UI freeze (CPU usage at 99% for about 1minute). It must be caused by the login, since the app is working whenever you are logged in.
In Xcode I can see also the famous
THREAD WARNING: ['InAppBrowser'] took '52.126953' ms. Plugin should use a background thread.
warning. Is this really significant ?
I am using the latest version of cordova and the version 4.1.0 of the ios platform.
Do you guys have any tips for me ? I also would really like to have some approaches to debug the issue with some external tools (Safari Debugger, does not really have any useful information for me there).
Thanks in advance !
EDIT : Added Code
authDialog.authenticate(URL_TO_LOGIN, function () {
console.log("success");
var inAppBrowserRef = cordova.InAppBrowser.open(URL_TO_LOGIN, '_blank', 'location=yes,hidden=yes');
inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);
inAppBrowserRef.addEventListener('loadstop', loadStopCallBack);
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
defer.resolve();
}, function (error) {
console.log("error xxx:", error);
defer.resolve();
}, username, password);
The following snippet might help you.
setTimeout(function(){
_self.openUrl(url) },300);
Related
I am building a cordova app for android and iOS that stores user information in a local database. However, I am unable to open a database connection on iOS.
The app works perfectly on android, but when I run it on iOS I get an error saying that window.sqlite is undefined. I have been searching the internet, but I can't find a related issue. I am not sure if my code has been setup incorrectly, or if I am missing some configuration for iOS. The SQLite plugin I am using "cordova-sqlite-evplus-legacy-free 0.9.1", and the cordova iOS version is "5.0.1".
db = window.sqlitePlugin.openDatabase({
name: 'test.db',
location: 'default',
//iosDatabaseLocation: 'Library'
},
function(db) {
if (clean_database) dumpDatabase();
else buildSchemaVersions();
},
function(error) {
db_error = error;
alert('Open database ERROR: ' + error.message);
})
First of all: I would strongly advise against using a plugin for which the last update has been made more than 2 years ago, especially if it is for something as important as the database of your app. It is very likely that it has not been properly tested on current version of iOS. Why not use the more active plugin cordova-sqlite-storage? I have been using this plugin for years now without any issues whatsoever (iOS and Android).
For the question itself:
Did you make sure to make the openDatabase call after the deviceready event?
Was the plugin correctly added to the iOS platform? Please try removing it and adding it again and look out for any errors when it is added to the iOS platform.
I have an issue on using InAppBrowser in ionic. My application developed by using ionic1 and Cordova plugin. I have installed cordova plugin add cordova-plugin-inappbrowser and injected in my controller and have used below code
$ionicPlatform.ready(function() {
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'yes',
closebuttoncaption: 'DONE?'
};
$cordovaInAppBrowser.open($scope.submiturl, '_blank', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
});
Error report shows,
THREAD WARNING: ['InAppBrowser'] took '175.479736' ms. Plugin should use a background thread.
This above code is working fine in android but it shows error in ios. Please help anyone to fix this issue. I'm opening payment gateway url on this link. I could not find out the solution even after lot of R&D.
As David said, this is just a warning. Cordova iOS triggers this warning when a call to a plugin blocks for more than 10ms. If this delay is not acceptable, to fix it you'll have to make changes to the inappbrowser plugin to make this method asynchronous.
we have migrated a worklight 6.1 application t IBM mobilefirst 7.0 platform and all the functionalities working as expected on the android environment, but in ios we are facing an issue: there is a function called "quick receipt". on click on a button the device camera opens and a photo is taken. The problem is that the photo is not displaying - it returns complete blank page this issue on ios device only but not on Android device.
Camera.DestinationType.FILE_URI is not working on IOS.
for security reason we wont share the code. here is similar prototype code.
html
<div><img alt="QuickReceipts" src="resources/img/camera.png" onclick="imgCapture();"</div>
JavaScript
imgCapture: function (){
navigator.camera.getPicture(this.onSuccess, this.onFail,{quality:80,destinationType:Camera.DestinationType.FILE_URI, targetWidth:600,targetHeight:1050}
},
onSuccess:function(imgData)
{
// applying the css and displaying the img
$("#imgReceipt").attr("src","data:image/jpeg;base64," +imgData);
$("#imgReceipt").css("display", "block");
}
onFail:function(imgData){
// failure msg
}
One suggestion is to attempt to code change as mentioned by Nazmul: http://www.telerik.com/forums/ios-cordova-3-5-0-camera-getpicture-targetwidth-issue.
Another suggestion is to upgrade to the latest 7.1 iFix from IBM Fix Central which contains several Cordova corrections and may address your issue.
If your issue is not resolved still, I suggest to open an IBM PMR (support ticket).
I'm pulling my hair out on this one. I'm using phonegap 3.4 to build an iOS app. When I build the project and run in the simulator, I want to view the output of console.log in the xcode debug window, but it's not working. I've installed the org.apache.cordova.console plugin, but no luck. I see some normal debug output like "Resetting plugins due to page load" but none of my console.logs appear. Any ideas?
And this did not solve my issue: console.log is not working in iOS Phonegap App even after adding the console plugin
try alert();
it is basically the same as console.log();
but you need to install different plugins: org.apache.cordova.dialogs
i dont have iphone nor mac so i can't guarantee it will work on them. But in one android device that i tried, when the console.log() fails. Alert() succeeds.
There are 2 types of alert:
alert('text'); //this is actually javascript
navigator.notification.alert(message, alertCallback, [title], [buttonName]) //this is phonegap function
In my case. i have only need to use the first one.
further documentation on the second alert function is below:
https://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.alert
i hope it will work on xcode too.
Make sure you install the console plugin. While Android is able to do this out of the box, logging to console is otherwise not supported on iOS:
https://github.com/apache/cordova-plugin-console/blob/master/doc/index.md
The solution is: call logger.__onDeviceReady function from your deviceready listener function:
function onDeviceReady() {
if (window.cordova.logger) {
window.cordova.logger.__onDeviceReady();
}
}
document.addEventListener('deviceready', onDeviceReady, false);
Try to use "document.write" instead.
From my extensive reading, the iOS 5.1 localStorage/WebSQL behavior change that Apple instituted has been fully rolled into Cordova 1.6.0.
However, while running on my (new) application on Cordova 1.7.0 and iOS 5.1.1, I am still seeing ugly, incorrect behavior.
I use window.localStorage to store and retrieve data. E.g.
window.localStorage.getItem("activeFormId")
window.localStorage.setItem("activeFormId", formId);
These work flawlessly during the same session of the Cordova-based app. If I background the app with the main iOS button then resume, that usually works as well.
However, the moment I kill the application (double-tap, long-press, tap the red circle) and relaunch, all localStorage data is lost. I have verified this with jsconsole.com as well.
Are there additional steps I need to take to ensure the persistence bug fixes are working? Any help is greatly appreciated.
Try using 1.7 - I had a similar issue and once I upgraded to 1.7 everything worked like it used to.
Try using localStorage vs window.localStorage syntax.
Also set what ever you're trying to call as a global variable...
var globalVar;
function onDeviceReady(){
globalVar = localStorage.getItem('something');
}