如何在本机脚本中集成Firebase身份验证?

时间:2019-03-28 09:48:56

标签: firebase firebase-authentication nativescript nativescript-firebase

在以本机脚本+ angular进行的Firebase初始化期间出错我正在使用native-script-plugin-firebase。它显示以下运行时错误: JS:错误错误:未捕获(在承诺中):TypeError:无法读取未定义的属性“ android” JS:TypeError:无法读取未定义的属性“ android”

home.component.ts
import firebase = require("nativescript-plugin-firebase");

firebase.init({ })
        .then(
            () => {
                console.log("firebase.init done");
            },
            error => {
                console.log(`firebase.init error: ${error}`);
            }
        );

2 个答案:

答案 0 :(得分:0)

我不确定,但语法应为const firebase = require("nativescript-plugin-firebase");

答案 1 :(得分:0)

使用以下代码段:

firebase
  .init({
    // Optionally pass in properties for database, authentication and cloud messaging,
    // see their respective docs and 'iOSEmulatorFlush' to flush token before init.
    iOSEmulatorFlush: true,
  })
  .then(
    () => {
      // console.log("firebase.init done: " + String(res));
    },
    (error) => {
      console.log("firebase.init error: " + String(error));
    }
  )
  .catch((err) => {
    console.log("firebase init error", err);
  });
相关问题