Code Monkey home page Code Monkey logo

cordova-plugin-ios-xhr's People

Contributors

globules-io avatar mike-nelson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-plugin-ios-xhr's Issues

XHR requests time out even though jQuery ajaxSettings timeout is set to higher value

Description
Ajax call (with long server processing time), done via jQuery, has timeout set to value higher than 60 seconds.
Request times out after 60 seconds, unfinished, resulting in ajax error.
Timeout value in ajax settings is not respected in the plugin.

Preferences

<preference name="NativeXHRLogging" value="full" />
<preference name="AllowUntrustedCerts" value="true" />
<preference name="InterceptRemoteRequests" value="all" />
<preference name="allowFileAccessFromFileURLs" value="true" />
<preference name="allowUniversalAccessFromFileURLs" value="true" />

Expected behavior
When using $.ajaxSettings.timeout of e.g. 180000, I expect the network request to only err/timeout after 180 seconds, not earlier.

Device

  • Device: iPad
  • OS: iOS 14.2
  • Browser: WKWebView
  • Hybrid app: Cordova build, using VoltBuilder

Example call

$.ajax({
  type: "POST",
  contentType: "application/json",
  url: "url_to_server_endpoint",
  dataType: "json",
  timeout: 180000,
  data: encodeURIComponent("someJSONdata"),
  success: function (data) {
    // ...
  },
  error: function(result,status,errorThrown) {
    // ...
  }
});

Issue with post ajax request and request at startup

Hello,

When I'm using this plugin with ajax request, the "async=false" parameter does not work, the program continue in next functions before came back in response of the request.
Of course I want to wait for the response of request before executing next functions in my code.

Also when I'm doing request at startup of my application, the error fixed by this plugin is present.

Thank you for your time,
neoCobol

Not allowed to load local resource

XCode 12.4
Cordova 6.0

Load image from local resource and Specifies the path to the image is local resource path

Device file path :
"file:///var/mobile/Containers/Data/Application/CE6CC1DD-2883-4FC8-932D-947242BC5020/Library/NoCloud/Driving_posture_V1_20140924_thumb.jpg "

simulator file path:
"file:///Users/mac2/Library/Developer/CoreSimulator/Devices/A78582B1-7A35-4530-B111-E464C058DCD2/data/Containers/Data/Application/ED800D6A-9E5B-42A5-99C7-56CFFB50B884/Library/NoCloud/Driving_posture_V1_20140924_thumb.jpg "

It work in simulator. But it's fail in device.

I got the below error.

Unhandled Promise Rejection: NotSupportedError: The operation is not supported.

Using the window.resolveLocalFileSystemURL() method check the file existence and it gives an Entry object corresponding to it, as long as that file exists within either the TEMPORARY or PERSISTENT filesystems.

File is existing in the path but not accessible.

BUG plugin leaves junk in package.json after uninstall

Describe the bug
After uninstalling using cordova plugin rm cordova-plugin-ios-xhr the following is left in package.json

    "devDependencies": {
        "@globules-io/cordova-plugin-ios-xhr": "^1.0.5",

Expected behavior
Not leaving anything in package.json after uninstall.

Desktop (please complete the following information):
My environment:

node 10.22
npm 6.14.6
cordova 10.0.0
cordova-ios 6.1.0
ios-deploy 1.11.0

Additional context
Somewhat connected with #4.

AllowUntrustredCerts no impact on iOS

Describe the bug
will not affect unsigned certificates

Expected behavior
https addresses are available without signed certificates

Screenshots
2020-10-14 11:00:38.056807+0200 SynMobile[2769:3014509] Task <8761796E-E397-4134-89AF-4995E3B21A4C>.<1> finished with error [-1202] Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.100.161” which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=( "<cert(0x13e80d200) s: fooi: foo>", "<cert(0x13e823800) s: fooi: foo>" ), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://192.168.100.161:8443/foo/Logon_mobile.action, NSErrorFailingURLStringKey=https://192.168.100.161:8443/foo/Logon_mobile.action, NSUnderlyingError=0x283d5de30 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x2801f9c20>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9807, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9807, kCFStreamPropertySSLPeerCertificates=( "<cert(0x13e80d200) s: fooi: foo>", "<cert(0x13e823800) s: fooi: foo>" )}}, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <8761796E-E397-4134-89AF-4995E3B21A4C>.<1>" ), _kCFStreamErrorCodeKey=-9807, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <8761796E-E397-4134-89AF-4995E3B21A4C>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x2801f9c20>, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.100.161” which could put your confidential information at risk.}

Smartphone (please complete the following information):

  • Device: iPad 9
  • OS: iOS 14.0.1

Additional context
I'm developing towards a localhost address, this setting will not make it into production but it might be that I have misunderstood what this setting actually does. More detailed explanations in the read.me would be nice

Wrong version in plugin.xml

package.json correctly contains 1.2.0
plugin.xml still says 1.1.0

Just lost a bit of time trying to work out why even after pulling from Github cordova plugin list was still reporting version 1.1.0!

BUG: getWebContentResourceURL: has fixed baseURL as mainBundle resourceURL

Describe the bug
If you change the initial cordova page to something other than "index.html" the plugin won't load relative path file:// resources correctly. It always tries to resolve relative URL resources from the www/ cordova folder. So, for example, if I have this directory tree for my app

www/
--foo/
----index.html
----script.js

When trying to load relative URL as script.js the plugin will resolve URL to be file://<all bundle IDs and Application IDs>/www/script.js and will return a 404 File Not Found error.

Paste your preferences

<!-- skipping not useful information -->
<content src="foo/index.html" />
<preference name="allowFileAccessFromFileURLs" value="true" />
<preference name="allowUniversalAccessFromFileURLs" value="true" />

Expected behavior
Method -(NSURL*)getWebContentResourceURL: (NSString*) uri from CDVWKWebViewFileXhr.m should resolve a relative URL script.js as www/foo/script.js

Additional context
Fixed the problem by changing lines 170 and 171 from mentioned method to

NSURL *baseURL = [[(WKWebView *)self.webView URL] URLByDeletingLastPathComponent];
NSString *wwwuri = uri;

This way, relative resources URL are always resolved from the current WKWebView location.

Send correct User-Agent header

Hello,
Using this plugin all requests comes with native iOS User-Agent header.

The header looks similar to this: "appName/3.0.10 CFNetwork/978.0.7 Darwin/18.7.0"
Expected value should be like this: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/604.1"

I see that all ajax calls send correct header, but in backend we get that iOS specific one. This is currently a problem to Authenticate with Microsoft Azure where conditional access policy enabled to check the device model. It simply can't recognize the device.

Could that be fixed?

Thank you!

'cordova-plugin-ios-xhr' is not in the npm registry

Not sure if this is a bug or if I'm doing something unexpected.
My environment:

node 10.22
npm 6.14.6
cordova 10.0.0
cordova-ios 6.1.0
ios-deploy 1.11.0
  1. I install using
    cordova plugin add @globules-io/cordova-plugin-ios-xhr
    which results in an added line in package.json cordova/plugins
    "cordova-plugin-ios-xhr": {}
    (When installing other plugins I also get a line with the plugin version or a git url in package.json devDependencies!?)
  2. As part of my build process I do
rm -fr node_modules
rm -fr plugins
rm -fr platforms
cordova platform add ios

which results in

Discovered plugin "cordova-plugin-ios-xhr". Adding it to the project
Command failed with exit code 1: npm view cordova-plugin-ios-xhr --json
npm ERR! code E404
npm ERR! 404 'cordova-plugin-ios-xhr' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! 404 
npm ERR! 404  'cordova-plugin-ios-xhr@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sven/.npm/_logs/2020-08-11T21_15_18_934Z-debug.log
{
  "error": {
    "code": "E404",
    "summary": "'cordova-plugin-ios-xhr' is not in the npm registry.\nYou should bug the author to publish it\n(or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url.",
    "detail": "\n 'cordova-plugin-ios-xhr@latest' is not in the npm registry.\nYou should bug the author to publish it (or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
  }
}

NOTE:
If I instead install using
cordova plugin add https://github.com/globules-io/cordova-plugin-ios-xhr
I get this line in package.json cordova/plugins
"cordova-plugin-ios-xhr": {}
and also this line in package.json devDependencies
"@globules-io/cordova-plugin-ios-xhr": "git+https://github.com/globules-io/cordova-plugin-ios-xhr.git"
If I manually add "@globules-io/cordova-plugin-ios-xhr": {} to package.json cordova/plugins everything seems to work as expected!

Is there an url length limit?

BUG

Hi,

While Install this plugin I got below issue.

cordova plugin add @globules-io/cordova-plugin-ios-xhr
Failed to fetch plugin cordova-plugin-ios-xhr via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 Not Found: cordova-plugin-ios-xhr@latest

npm ERR! A complete log of this run can be found in:

Not loading local files

This plugin is not working for me.

I understand this was done as a fix for cordova-plugin-wkwebview-file-xhr which worked ok for my app, until cordova-ios 6

My app loads the html and js files using JS and ajax, but they are not working.

Am I doing something wrong or?

Complete Installation Guide

The plugin is not working for me, i still get "Origin null is not allowed by Access-Control-Allow-Origin" errors on iOS devices.

Can someone post a full guide how to use this plugin please.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.