我想集成Fabric Crashlytics,但它对我不起作用。我已经集成了chrashlytics,但是当我在模块中导入Crashlytics时,它返回了我一个错误。我有添加插件链接
ionic cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=asdjfkjasldfjklajsdfkljasldjfl--variable FABRIC_API_SECRET=asdfasdfasdfasdfasd
npm install --save @ionic-native/fabric@4
然后我像这样在module.ts中添加了Crashlytics
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DatePipe } from '@angular/common';
import { Crashlytics } from '@ionic-native/fabric/';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
Crashlytics,
DatePipe,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
然后我像这样在home.ts中添加Crashlytics
import { Component } from '@angular/core';
import { DatePipe } from '@angular/common';
import { Crashlytics } from '@ionic-native/fabric';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss']
})
export class Tab1Page {
constructor(public datepipe: DatePipe,
private crashlytics: Crashlytics
){
try {
throw new Error("this is javascriptError");
}
catch (e) {
this.crashlytics.addLog("Error while loading data");
this.crashlytics.sendNonFatalCrash(e.message || e);
}
}
myTime: String = this.datepipe.transform(new Date().toISOString(), 'hh:mm');;
myDate: String = this.datepipe.transform(new Date().toISOString(), 'MMM dd, yyyy');;
}
这是我的错误日志
vendor.js:75062 Uncaught TypeError: Object(...) is not a function
at vendor.js:75062
at Module../node_modules/@ionic-native/fabric/index.js (vendor.js:75164)
at __webpack_require__ (runtime.js:84)
at Module../src/app/app.module.ts (main.js:1036)
at __webpack_require__ (runtime.js:84)
at Module../src/main.ts (main.js:1114)
at __webpack_require__ (runtime.js:84)
at Object.0 (main.js:1137)
at __webpack_require__ (runtime.js:84)
at checkDeferredModules (runtime.js:46)
请仔细查看并帮助我解决
答案 0 :(得分:0)
如the Ionic Native documentation中所述:
对于Angular,导入路径应以
/ngx
结尾
所以:
import { Crashlytics } from '@ionic-native/fabric';
应为:
import { Crashlytics } from '@ionic-native/fabric/ngx';
答案 1 :(得分:0)
您需要安装:
AVAudioPlayer
并导入:
npm install @ionic-native/fabric@latest