我有一个 ionic 项目,要求我将 ionic 中的文件写入移动设备。这可以使用 Cordova 的
cordova-plugin-file
和 @ionic-native/file
来实现。
当我将插件添加到我的项目时,它抛出以下错误。
Channel not fired: onFileSystemPathsReady
Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
离子信息:
Ionic CLI : 7.2.0
Ionic Framework : @ionic/angular 8.4.1
@angular-devkit/build-angular : 16.2.15
@angular-devkit/schematics : 16.2.15
@angular/cli : 16.2.15
@ionic/angular-toolkit : 11.0.1
Cordova:
Cordova CLI : 12.0.0 ([email protected])
Cordova Platforms : android 9.1.0, ios 6.2.0
cordova-plugin-file : version 5.0.0
app.module.ts 文件:
import { File } from "@ionic-native/file/ngx";
@NgModule({
declarations: [AppComponent, ModalPage, CustomIonicModalComponent],
imports: [
MatDialogModule,
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
FormRendererModule,
FormsModule,
BrowserAnimationsModule
],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, MobileService, Keyboard, File],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts 文件:
import { File } from '@ionic-native/file/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor(private file: File) {}
}
我尝试解决此问题的方法:
@ionic-native 已被弃用,您需要更新到 Awesome-cordova-plugins。