Ionic 4 Http Plugin Crashing App
See original GitHub issueBug Report
Ionic Info
Run ionic info
from a terminal/cmd prompt and paste the output below.
Ionic:
ionic (Ionic CLI) : 4.1.2 (C:\Users\patrick.kelly\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.8
@angular-devkit/core : 0.8.1
@angular-devkit/schematics : 0.8.1
@angular/cli : 6.2.1
@ionic/ng-toolkit : 1.0.8
@ionic/schematics-angular : 1.0.6
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.3, (and 8 other plugins)
System:
Android SDK Tools : 26.1.1 (C:\Users\patrick.kelly\AppData\Local\Android\Sdk)
NodeJS : v9.3.0 (C:\Program Files\nodejs\node.exe)
npm : 5.5.1
OS : Windows 10
Describe the Bug When trying to make an API call using Ionic Native HTTP plugin the application crashes and shuts down.
When the application only has the Ionic Native HTTP plugin the plugin works.
This only happens when the Launch Navigator plugin is installed: the Launch Navigator works in isolation and when both are installed.
I have traced the error point to cordova.js line 926: var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
No console error is written the application just shuts down and the debugger disconnects.
Steps to Reproduce Steps to reproduce the behavior:
1.Create a blank app ionic start myApp blank --type=angular
-
Install ionic http ionic cordova plugin add cordova-plugin-advanced-http npm install --save @ionic-native/http@5.0.0-beta.17
-
Install ionic launch navigator ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator npm install --save @ionic-native/launch-navigator@5.0.0-beta.17
-
add HTTP as a provider in home module
-
import, inject and use the HTTP in the home.page.ts
-
call the use of the HTTP from the html of the page
Related Code ** home.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { HTTP } from '@ionic-native/http/ngx';
import { HomePage } from './home.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild([
{
path: '',
component: HomePage
}
])
],
declarations: [HomePage],
providers: [HTTP]
})
export class HomePageModule {}
**home.page.ts
import { Component } from '@angular/core';
import { HTTP } from '@ionic-native/http/ngx';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor(
private http: HTTP
) {
}
getStuff() {
this.http.get('https://www.google.co.uk', null, null).then((success) => alert('success'), (error) => alert('error'));
}
}
**home.page.html
<ion-header>
<ion-toolbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
The world is your oyster.
<p>If you get lost, the <button (click)="getStuff()" >Get Stuff</button> will be your guide.</p>
</ion-content>
Expected Behavior I would expect the application to make the api call, not crash and close.
Additional Context Please let me know if I should post this on another Github repo.
I have tried the HTTP plugin in conjunction with the camera plugin and both plugins work correctly here.
When I am adding and removing the plugins I always remove them from the config.xml and remove both the platforms and plugins folder from my workspace
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
I’m also using LaunchNavigator feature in my app and as I tried to use Native Http using cordova-plugin-advanced-http it crashes the app.
Any solution for this?
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.