Use cordova-plugin-advanced-http


#1

Ionic is supporting cordova-plugin-http with their @ionic-nativ/http lib, but there are some problems with the lib and there are other forks which works probably better
a) https://github.com/silkimen/cordova-plugin-advanced-http
b) https://github.com/LlamaloX/cordova-plugin-advanced-http-2

I tried to integrate the first plugin, installing it with ionic cordova plugin add cordova-plugin-advanced-http, the next thing I did is creating a plugin file as copied from ionic native on github and changed it to use new plugin, this is my example code

@Plugin({
    pluginName: 'HTTP',
    plugin: 'cordova-plugin-advanced-http',
    pluginRef: 'cordovaHTTP',
    repo: 'https://github.com/silkimen/cordova-plugin-advanced-http',
    platforms: ['Android', 'iOS']
})
@Injectable()
export class HTTP extends IonicNativePlugin {

I changed plugin and repo property

But at the end in the emulator and on device I got this error:

Native: tried calling HTTP.post, but the HTTP plugin is not installed
Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http’
But I had installed this before, so I’m really not the expert on cordova and plugins! :expressionless: Some ideas?

I already opened a feature request to support this from ionic team with ionic-native, feel free to vote for it :smile::smile:


How to use ionic native HTTP to perform a post with body and header
#2

From https://github.com/wymsee/cordova-HTTP:

This plugin registers a cordovaHTTP global on window

From https://github.com/silkimen/cordova-plugin-advanced-http:

This plugin registers a global object located at cordova.plugin.http.

From https://github.com/LlamaloX/cordova-plugin-advanced-http-2:

This plugin registers a global object located at cordova.plugin.http.

So these both use a different global object to put there functionality in than the original plugin, that is why the Ionic Native plugin doesn’t just work.

You will probably have to use them directly - or fix this.


#3

Does this mean that the Ionic Native wrapper for this wont work or that some additional configuration is needed?

I couldnt find the object on the window when I tested with the silkimen version?


#4

Yes, the wrapper works only with the linked plugin if the other plugins are different in e.g. the object name they put into global JS namespace. This seems to be the case here.


#5

Ionic Native now or better from a while is using this cordova plugin which works much better and is much better maintained!

THX GUYS


#6

Hi,
I have successfully implemented certificate pinning with the help of this plugin.
Kindly help me regarding error coming most of the time i login. Login is inconsistent. Sometimes able to login but many times giving below errors
1)There was an error with the request: java.net.ConnectException: Failed to connect to “url”
2)The request is timeout

Kindly help me i am stuck in this and project cannot be successfull if this login inconsistency persist.

Does anyone face such issues. What can be the cause of this issue? Kindly enlighten in this subject.

To fix the issue of timeout i tried below IONIC forums links but not succeeded.



#7

SSL Pinning example :sunglasses: