0

我正在为 Google Assistant 开发一个应用程序,但总是在我尝试获取用户信息(如姓名或位置)时,在我获得用户权限后应用程序崩溃,并且在下一次我启动应用程序并授予权限时在同一步骤中再次崩溃。

app.handle('create_user', async (conv) => {
  const payload = conv.user.params.tokenPayload;
  // write user name in session to use in dialogs
  conv.user.params.name = payload.given_name;
  const email = payload.email;
  if (email) {
    try {
      conv.user.params.uid = (await auth.getUserByEmail(email)).uid;
    } catch (e) {
      if (e.code !== 'auth/user-not-found') {
        throw e;
      }
      // If the user is not found, create a new Firebase auth user
      // using the email obtained from the Google Assistant
      conv.user.params.uid = (await auth.createUser({email})).uid;
    }
    const userDoc = dbs.user.doc(conv.user.params.uid);
    const orderHistoryColl = userDoc.collection(orderHistory);
    for (let i = 0; i < options.length; i++) {
      await orderHistoryColl.doc(options[i]).set(
          {option: options[i], count: 0});
    }
  }
});
4

0 回答 0