PhoneGap iOS + DOM Exception 18 - javascript

I'm going a window.onerror "SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent." Each time I load my iOS PhoneGap app. THe app uses local storage and webSQL. I have isolated this error to be throw when I open my db using: db = window.openDatabase("db", "1.0", "Test DB", 1000000);
I haven't had this issue before and my code hasn't changed - this just came out of now where. I've been looking at the iOS 5.1 web view storage bugs and fear it may be related.
Help?

It's a confirmed Apple bug in iOS 5.1. Details here in this PhoneGap/Cordova issue tracker: https://issues.apache.org/jira/browse/CB-347

I have used this and It is working perfectly.Try this
try {
if (!window.openDatabase) {
alert('not supported');
} else {
var shortName = 'WineDatabase';
var version = '1.0';
var displayName = 'PhoneGap Test Database';
var maxSize = 655367; // in bytes
mydb = openDatabase(shortName, version, displayName, maxSize);
}
} catch(e) {
// Error handling code goes here.
if (e == INVALID_STATE_ERR) {
// Version number mismatch.
alert("Invalid database version.");
} else {
alert("Unknown error "+e+".");
}
return;
}
EDIT:
At that time I was using Phonegap on ios.So I hadn't get it,Now on blackberry phonegap I am getting same issue and and found the cause that: while datacable is plugged app is not able to write anything on SDCard.So I unplugged it and run working fine.Sorry buddy not the solution for ios But people who are searching this issue for blackberry can use this solution.

Related

Detecting device's IOS version with ionic

I have an ionic application for android and IOS, the app display a message when specific action happen.
But i realized that there is a difference in this action if the IOS OS was higher than 11 or less than 10.
So i want to detect IOS' version, if it was less than 10 display this message and if it was higher then don't displau it.
I'm new to ionic, so how can i achive this?
CODE:
function (err) {
if (err == "has no access to assets") {
_this.presentAlert('no access');
}
else if (err == "no image selected") {
_this.presentAlert('nothing selected');
}
});
The first if is where i want to check the device's OS version, if it was less than 11 then display the message.
How to do it?
for version: const currentPlatformVersion = ionic.Platform.version();
if it is ios device const isIOS = ionic.Platform.isIOS();
even this const deviceInformation = ionic.Platform.device(); returns an object with the device that runs the ionic app.

Android CloudRail Branded site fails - "Unexpected token )" (community.js line 18)

Since yesterday i can't login to dropbox account using Android CloudRail Integration. My code is as simple as this:
CloudRail.setAppKey([License Key]);
final CloudStorage cs = new Dropbox(this.getApplicationContext(), "[clientIdentifier]", "[clientSecret]");
new Thread() {
#Override
public void run() {
cs.createFolder("/TestFolder"); // <---
InputStream stream = null;
try {
AssetManager assetManager = getAssets();
stream = assetManager.open("UserData.csv");
long size = assetManager.openFd("UserData.csv").getLength();
cs.upload("/TestFolder/Data.csv", stream, size, false); // <---
} catch (Exception e) {
// TODO: handle error
} finally {
// TODO: close stream
}
}
}.start();
All i'm getting is "Connecting to Dropbox" page and
I/chromium: [INFO:CONSOLE(18)] "Uncaught SyntaxError: Unexpected token )", source: https://integrations.cloudrail.com/community.js (18)
in Android Studio console.
Line 18 is:
setTimeout(() => { //line 18
window.location.href = redirectUrl;
}, 3000);
I'm using a few real devices (Android 5, 6, 7) and some emulated ones. One or two devices are still working (quite slow).
Help me please. Is this some temporary issue of Cloudrail? I couldn't find any info. I haven't changed anything recently.
We updated the community authentication page which probably introduced the issue. I just realized that the lambda notation is not supported on some mobile device so I reverted to the old way of doing it. Could you please validate that it works now.

indexedDB with CDWKWebViewEngine in PhoneGap Build cli-6.0.0

I'm having trouble opening an indexedDB store when using CDWKWebViewEngine within an app build with PhoneGap Build 6 running on iOS 9.2. window.indexedDB is not null and appears to be of type IDBFactory but when I use the code below I get "InvalidAccessError" reported.
var request = window.indexedDB.open("MyTestDatabase", 1);
request.onerror = function (event) {
alert("Database error: " + request.error.name);
};
Has anyone been able to get indexedDB working in the environment I've described?

Cordova In App Browser event not firing IOS

Trying to authenticate users on my ionic application through an external service and I need to use cordovas In app browser! The code works perfectly on android however on iOS the "loadstop" event never fires and thus, the browser never redirects itself back to the application. The code I have looks like this:
$rootScope.$on('$cordovaInAppBrowser:loadstop', function (e, event) {
console.log('inappbrowser loaded', event);
var regex = /* regex to determine if url is correct redirected url */
var res = regex.test(event.url);
alert('loaded: ' + event.url);
alert('regex result: ' + res);
if(res === true) {
$cordovaInAppBrowser.close();
}
});
if(okta) {
if (typeof window.localStorage.msRefreshToken === 'undefined') {
document.addEventListener('deviceready', function () {
$cordovaInAppBrowser.open('urlforExternalservicehere', '_blank', options);
}, false);
} else {
TokenStore.refreshAccessToken();
}
}
when the code is run no alert appears on the screen. Also, once the app has reached the external service and the username of the user is entered, it is then redirected to another url, which the user will then use another set of credentials to authenticate against. This in turn returns a token for the application to authenticate use.
Thus, in a perfect iOS world where it matches the current android experience, the loadstop event fires three times, and the third time the "loadstop" event would fire and the regex would return true and close the in app broswer.
If I need to supply more code to help solve this issue please let me know!
Cordova Version: 4.2.0
Ionic: 1.4.5
iOS: 8 and 9
Using NgCordova for Cordova functionality
UPDATE: when running the application on an emulator and checking the console logs, I find this error:
Error: Module cordova-plugin-inappbrowser.inappbrowser does not
exist., http://10.117.1.46:8100/cordova.js, Line: 1402
I have the plugin installed so I don't know how its missing the plugin. Does anyone have a remedy for this? Thanks!
iabRef = window.open('http://XYZ.php', '_blank', 'location=no,toolbar=no');
iabRef.addEventListener('loadstart', iabLoadStart);
iabRef.addEventListener('loadstop', iabLoadStop);
iabRef.removeEventListener('loaderror', iabLoadError);
iabRef.addEventListener('exit', iabClose);
iabRef.addEventListener('loadstart', function(event) {
if (event.url.match("mobile/close")) {
iabRef.close();
window.location = 'index.html';
}
}
);
Problem was my iOS platform wasn't latest.
So when you developing apps using cordova make sure your platform versions and plugins are up-to date with OS upgraded.
So all I had to do is
Removing iOS platform.
cordova platform rm ios
Adding iOS platform - Latest Version
cordova platform add ios
Removing the plugin cordova-plugin-inappbrowser
cordova plugin remove cordova-plugin-inappbrowser
Adding the plugin cordova-plugin-inappbrowser - Latest Version
cordova plugin add cordova-plugin-inappbrowser

Can't access the camera from the app on Lumia 520 (running Windows Phone 8.1 Preview)

I am a WP dev beginner and learning how to write a simple video recorder app. I am using javascript and HTML on VS Pro 2013 and debugging on my actual device Lumia 520 (running Windows Phone 8.1 Preview). I read through a body of documentations and found that the MediaCapture class was the core class for this purpose. So I started following some tutorials and wrote up some functions to access the camera and display a preview in a HTML5 video tag. However, I wasn't successful in getting the MediaCapture object initialized, not even displaying the preview. Below are the major functions of which the first one was problematic:
function initCapture() {
findRearFacingCamera().then(function (cameraId) {
try {
if (cameraId != null && cameraId != "") {
// Initialize the settings
captureInitSettings = null;
captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
captureInitSettings.videoDeviceId = cameraId;
captureInitSettings.streamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.video;
captureInitSettings.photoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.videoPreview;
captureInitSettings.realTimeModeEnabled = true;
// Initialize the capture
oMediaCapture = null;
oMediaCapture = new Windows.Media.Capture.MediaCapture();
oMediaCapture.initializeAsync(captureInitSettings).then(preview, errorHandler);
}
} catch (e) { }
});
}
function preview() {
var preview = document.getElementById("PreviewScreen");
preview.msZoom = true;
if (preview != null) {
preview.src = URL.createObjectURL(oMediaCapture);
preview.play();
}
}
function errorHandler(e) {
var information = document.getElementById("message");
information.innerHTML = e.message;
}
During debugging, I paused at the statement oMediaCapture = new Windows.Media.Capture.MediaCapture(); in the initCapture() function. At this point, captureInitSettings.videoDeviceId has the value: "\\?\DISPLAY#QCOM_AVStream#3&25691128&0&UID32768#{e5323777-f976-4f5b-9b55-b94699c46e44}\Back Sensor", which I believed was a correct identification of the rear camera that I intended to use. Then, when I continued with a break point set at var preview = document.getElementById("PreviewScreen"); in function preview(), which was supposed to be called upon successful initialization of the MediaCapture object, the program was trapped into the errorHandler() function instead, with the error message being "Access is denied" with error number "-2147024891". So I guess the problem rose from the .initializeAsync() function, which was unsuccessful. Deeper causes might also be related to the permission to access the camera. BTW, I have enabled the webcam and microphone capabilities for this app, which was not the issue.
I believe I was missing something either in the code or in the big picture of the development settings. Please help me identify the issue and let me know if any additional information is needed. Much appreciated!
Did you make sure you added the Rear Camera requirement in your Package Manifest?
Turned out the problem was really with my device. Recall that I was testing on a Lumia 520 with Windows Phone 8.1 preview, the firmware stayed at Lumia Black. After upgrading the firmware to Lumia Cyan (parallel to Windows Phone 8.1) using the Nokia Recovery Software Tool, the problem disappeared.

Categories

Resources