用于推送通知的Firebase本机需要在ionic3中使用ngx

时间:2019-04-16 11:05:50

标签: angular firebase ionic-framework ionic3

如果没有在ngx中使用本地的firebase,则会出现错误,指出在ionic3应用程序中将firebase original用作类型而不是值。如果我更新到ionic4,它会不断给我一些其他与插件相关的错误。我想继续使用ionic3并使用Firebase推送通知

import { Firebase } from '@ionic-native/firebase';
import { AngularFirestore } from 'angularfire2/firestore';
import { UserProvider } from '../../providers/user/user';
import firebase from 'firebase';
import { server_key } from '../../app/app.angularfireconfig';
@Injectable()
export class FcmProvider {
userId;
fireuserStatus = firebase.database().ref('/userstatus');

constructor(
public userservice: UserProvider,
private http: Http,
public firebaseNative: Firebase,
public afs: AngularFirestore,
public platform: Platform
) {
}

// Get permission from the user
async getToken() {

let userID = localStorage.getItem('userUID');
if (userID != undefined) {
this.userId = userID;
} else {
this.userId = firebase.auth().currentUser.uid;
}
let token;
if (this.platform.is('android')) {
token = await this.firebaseNative.getToken();

this.firebaseNative.onTokenRefresh()
.subscribe((token: string) => {
this.userservice.updateDeviceToken(token, this.userId);
});
}

我尝试删除node_modules文件夹。删除平台android。再次添加。运行命令npm i再次安装node_modules文件夹。问题依然存在

推送通知应该起作用。现在,消息传递工作正常,但是当我尝试启用推送通知时,插件冲突就出现了

0 个答案:

没有答案