Ionic 中 'firebase' 模块和 Ionic Native 的 "Firebase" 模块有什么区别
What's the difference between the 'firebase' module, and the "Firebase" one from Ionic Native, in Ionic
目前发现 问题(这也让我感到困惑),但我目前正在使用 "firebase" 进行身份验证,并使用 "Firebase" 从 Ionic Native 获取 Firebase 上的分析数据安慰。我认为其中一个是多余的(因为我有一次 Firebase 初始化数据作为代码中的对象,另一个在 google-services.json)。
那么有什么区别,这两个包是可以互相替代,还是有别的东西呢
你在 ionic 中谈论 node-modules。如果我理解使用它,我会使用它。我的经验告诉我它不能相互替代。让我们谈谈模块。
首先如果使用:
从 'firebase' 导入 Firebase
或
从 "firebase";
导入 * 作为 Firebase
- 使用数据快照、快照、快照。
- 如果我需要从 firebase 示例中获取数组数据的对象:
import firebase from 'firebase';
this.addProduct = firebase.database().ref('/product-List');
this.addProduct.on('value', snapshot => {
this.productList = [];
snapshot.forEach( snap => {
this.productList.push({
category: snap.val().category,
id: snap.key,
in_stock: snap.val().in_stock,
name: snap.val().name,
downloadURL: snap.val().downloadURL,
short_description: snap.val().short_description,
description: snap.val().description,
regular_price: snap.val().regular_price,
sale_price: snap.val().sale_price,
brand: snap.val().brand,
vendor: snap.val().vendor
});
});
});
}
另一个node-modulesionic-native/firebase
从“@ionic-native/firebase”导入 {Firebase};
- 用于推送通知、事件跟踪、崩溃报告、分析等的插件。
- 就我而言。我使用 phone 登录并验证电话号码示例:
import {Firebase} from '@ionic-native/firebase';
constructor(private firebasePlugin: Firebase) {
}
Private registerPhone(): void {
if (!this.phoneNumber.value) {
alert('Mohon isi nomor telepon anda');
return;
}
const appVerifier = this.recaptchaVerifier;
const phoneNo = '+62' + this.phoneNumber.value;
if (this.platform.is('cordova')) {
try {
this.firebasePlugin.verifyPhoneNumber(phoneNo, 60).then (credential=> {
// alert("SMS Kode Verifikasi Berhasil dikirim ke Nomor Telp anda");
console.log(credential);
this.showPrompt(credential.verificationId);
}).catch (error => {
console.error(error);
});
}catch(error){alert(error.message)}
}
}
目前发现
那么有什么区别,这两个包是可以互相替代,还是有别的东西呢
你在 ionic 中谈论 node-modules。如果我理解使用它,我会使用它。我的经验告诉我它不能相互替代。让我们谈谈模块。
首先如果使用:
从 'firebase' 导入 Firebase 或
从 "firebase";
导入 * 作为 Firebase- 使用数据快照、快照、快照。
- 如果我需要从 firebase 示例中获取数组数据的对象:
import firebase from 'firebase';
this.addProduct = firebase.database().ref('/product-List');
this.addProduct.on('value', snapshot => {
this.productList = [];
snapshot.forEach( snap => {
this.productList.push({
category: snap.val().category,
id: snap.key,
in_stock: snap.val().in_stock,
name: snap.val().name,
downloadURL: snap.val().downloadURL,
short_description: snap.val().short_description,
description: snap.val().description,
regular_price: snap.val().regular_price,
sale_price: snap.val().sale_price,
brand: snap.val().brand,
vendor: snap.val().vendor
});
});
});
}
另一个node-modulesionic-native/firebase
从“@ionic-native/firebase”导入 {Firebase};
- 用于推送通知、事件跟踪、崩溃报告、分析等的插件。
- 就我而言。我使用 phone 登录并验证电话号码示例:
import {Firebase} from '@ionic-native/firebase';
constructor(private firebasePlugin: Firebase) {
}
Private registerPhone(): void {
if (!this.phoneNumber.value) {
alert('Mohon isi nomor telepon anda');
return;
}
const appVerifier = this.recaptchaVerifier;
const phoneNo = '+62' + this.phoneNumber.value;
if (this.platform.is('cordova')) {
try {
this.firebasePlugin.verifyPhoneNumber(phoneNo, 60).then (credential=> {
// alert("SMS Kode Verifikasi Berhasil dikirim ke Nomor Telp anda");
console.log(credential);
this.showPrompt(credential.verificationId);
}).catch (error => {
console.error(error);
});
}catch(error){alert(error.message)}
}
}