cordova-plugin-advanced-http is a Cordova/PhoneGap plugin that enables mobile applications to perform HTTP requests using native networking capabilities, offering significant advantages over standard JavaScript requests. Key differentiators include robust SSL/TLS pinning for enhanced security, bypassing browser-imposed CORS restrictions, support for X.509 client certificate-based authentication, and improved handling of HTTP 401 Unauthorized responses. The current stable version is 3.3.1. While there isn't an explicit release cadence, the project is actively maintained with updates detailed in its `CHANGELOG.md`. This plugin is particularly valuable for applications requiring secure communication channels and those needing to circumvent typical webview networking limitations on iOS, Android, and Browser platforms.
npm install cordova-plugin-advanced-httpVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize and use `cordova-plugin-advanced-http` after the `deviceready` event, including setting global headers, configuring data serializers, and making basic GET and POST requests.
Always wrap calls to `cordova.plugin.http` methods within a `document.addEventListener('deviceready', handler, false)` callback.Implement custom timeout mechanisms or design application flow to tolerate unreliable request cancellation. Avoid relying on the plugin's native abort mechanism for critical operations.
Ensure all `.cer` files are correctly DER-encoded and placed in the specified directories. Thoroughly test pinning against your target server environments (development, staging, production) and manage certificate expiry. Use `setServerTrustMode('nocheck')` *only* for testing, never in production.Utilize comprehensive server-side logging or integrate dedicated mobile debugging proxies (e.g., Charles Proxy, Fiddler) to inspect native HTTP traffic. For debugging within the app, add extensive `console.log` statements around API calls.
For nested data, always use `setDataSerializer('json')`. If `urlencoded` is required, flatten your data object or manually serialize complex parts before passing them to the plugin.Regularly review and update the `AndroidBlacklistSecureSocketProtocols` preference in `config.xml` with current recommendations for secure protocols. Consult Android's SSLSocket documentation for valid protocol names and industry best practices for TLS configuration.
Ensure all plugin calls are within a `document.addEventListener('deviceready', function() { /* plugin code here */ }, false);` block.Verify that your `.cer` files are DER-encoded, up-to-date, and correctly placed in `platforms/android/app/src/main/assets/certificates` (or `www/certificates` in older setups). Ensure you are pinning against the correct server certificate or a valid intermediate/root CA.
Double-check that `cordova-plugin-advanced-http` is installed (`ionic cordova plugin add cordova-plugin-advanced-http`) and that `@ionic-native/http` is also installed (`npm install @ionic-native/http`). Ensure your `app.module.ts` correctly declares and provides `HTTP` from `@ionic-native/http/ngx`. Sometimes, rebuilding the project (`ionic cordova platform rm android && ionic cordova platform add android`) is necessary.
Check device network connectivity. Verify the requested URL is correct and accessible. Inspect server logs for errors. Ensure your `config.xml` and platform-specific manifests have necessary network permissions (e.g., `android.permission.INTERNET`, `android.permission.ACCESS_NETWORK_STATE`).