[英]Ionic 4 native plugin not working
I am facing a problem with Ionic 4 native plugins. 我正面临着Ionic 4原生插件的问题。 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. 我已经安装了离子4 Cordova原生插件 “Geolocation” ,但当我将应用程序运行到我的iOS或Android设备时,它向我显示一个空白的白色屏幕,没有任何事情发生。
app.module.ts
code: app.module.ts
代码:
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: Home.ts
代码:
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. 但它正致力于Ionic 3项目。
Anyone can give me any idea why it's happening and what I did wrong. 任何人都可以告诉我为什么会发生这种情况以及我做错了什么。
I've found the solution : 我找到了解决方案:
@ionic-native/geolocation
to 5.0.0-beta.14 (same as @ionic-native/core
) 打开你的package.json并将@ionic-native/geolocation
更新为5.0.0-beta.14 (与@ionic-native/core
) import {Geolocation} from '@ionic-native/geolocation/ngx';
更新所有导入: import {Geolocation} from '@ionic-native/geolocation/ngx';
(in app.module.ts and in your component.ts file) (在app.module.ts和component.ts文件中)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.