3

I am facing a problem with Ionic 4 native plugins. I have installed ionic 4 Cordova native plugin "Geolocation" but when I run the app into my iOS or Android device it's showing to me a blank white screen and nothing happening.

app.module.ts code:

import {
  Geolocation
} from '@ionic-native/geolocation';
@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    ComponentsModule
  ],
  providers: [
    StatusBar,
    SplashScreen, ** Geolocation ** , {
      provide: RouteReuseStrategy,
      useClass: IonicRouteStrategy
    }
  ],
  bootstrap: [AppComponent]
})

Home.ts code:

import {
  Geolocation
} from '@ionic-native/geolocation';
constructor(private geolocation: Geolocation) {}

I don't know why it's happening. But It's working on Ionic 3 project.

Anyone can give me any idea why it's happening and what I did wrong.

4

1 回答 1

10

I've found the solution :

  • open your package.json and update @ionic-native/geolocation to 5.0.0-beta.14 (same as @ionic-native/core)
  • npm install
  • update all your imports : import {Geolocation} from '@ionic-native/geolocation/ngx'; (in app.module.ts and in your component.ts file)
于 2018-08-01T09:06:05.180 回答