标签: rxfire

如果没有“new”,则无法调用 AngularFire 身份验证持久性

我正在尝试使用以下代码在 AngularFire 中实现持久性身份验证:

constructor(private auth: Auth, private router: Router) {
    if (auth.currentUser) this.router.navigate(this.redirect);
  }

  async loginWithGoogle() {
    const provider = new GoogleAuthProvider();

    try {
      await setPersistence(this.auth, browserLocalPersistence);
      await signInWithPopup(this.auth, provider);
      this.message = 'Sign in successful';
      await this.router.navigate(this.redirect);
    } catch (error: any) {
      console.error(error);
      if (error.code) {
        this.message = `${error.code}: ${error.message}`;
      } else {
        this.message = 'There was a problem signing in. Please try again.';
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

但是,无论方法的位置如何,我总是收到此错误setPersistence

Class constructor BrowserLocalPersistence cannot be invoked without 'new'
Run Code Online (Sandbox Code Playgroud)

我按照文档(https://firebase.google.com/docs/auth/web/auth-state-persistence …

firebase firebase-authentication angularfire2 angular rxfire

6
推荐指数
1
解决办法
1500
查看次数

错误:尝试上传大图像文件时未找到存储/对象

尝试使用 RxFire 在 Google Cloud Storage 中上传大型图像文件时,出现错误:存储/未找到对象。

\n\n

他们说在桶中找不到该图像,但当我检查时,我看到了它们!

\n\n

我用小图像(可能是 100kb...)进行了测试,效果很好。

\n\n

但尝试使用 > 500kb 图像,不起作用......

\n\n
upload$\n  .pipe(\n    switchMap((event: any) => {\n      const name = Math.random().toString(36).substring(5);\n      const blob = event.target.files[0];\n      const type = blob.type.replace(\'image/\', \'\');\n      const ref = storage.ref(`uploads/test/${name}.${type}`);\n      return put(ref, blob);\n    }),\n    map(snapshot => snapshot),\n    filter(snapshot => snapshot.totalBytes === snapshot.bytesTransferred),\n    mergeMap(snapshot => getDownloadURL(snapshot.ref))\n  )\n  .subscribe(url => {\n    console.log(\'Results\', url)\n  }, (error) => {\n    // ERROR HERE\n    console.log(\'error\', error)\n  })\n
Run Code Online (Sandbox Code Playgroud)\n\n

预期结果:上传处理大图像

\n\n

实际结果:错误

\n\n
Uncaught t\xc2\xa0{code_: "storage/object-not-found", …
Run Code Online (Sandbox Code Playgroud)

google-cloud-storage firebase firebase-storage rxfire

3
推荐指数
1
解决办法
8186
查看次数

如何使用rxfire和rxjs(OR查询)加入两个Firestore查询

我们的目标很简单:将两个公司的FireStore查询利用rxjs,rxfire以及rnfirebase反应机库.

我读过多教程1,2上加入查询,但他们都失败,不同的错误.

//Simple test for collectionData
import { collectionData } from 'rxfire/firestore';

this.myQuery = this.props.docRef.collection(`messages`).where('read', 'array-contains', this.props.me.uid)
collectionData(this.myQuery, 'id').subscribe(docs => console.log(docs))
//Fails with error: this._next is not a function.
Run Code Online (Sandbox Code Playgroud)

或者,

this.publicQuery = this.props.docRef.collection('messages').where('public', '==', true) 
this.myQuery = this.props.docRef.collection(`messages`).where('read', 'array-contains', this.props.me.uid)
const myQuery$ = new Rx.Subject();
const publicQuery$ = new Rx.Subject();
this.myQuery.onSnapshot((querySnapshot) => {
    myQuery$.next(querySnapshot.docs.map(d => d.data()  ));
});
this.publicQuery.onSnapshot((querySnapshot) => {
    publicQuery$.next(querySnapshot.docs.map(d => d.data()  ));
});
const orQuery$ = combineLatest(this.myQuery, …
Run Code Online (Sandbox Code Playgroud)

rxjs firebase google-cloud-firestore rxfire

2
推荐指数
1
解决办法
581
查看次数