2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

firebase 9からはsetPersistenceが変わりました!Argument of type 'string' is not assignable to parameter of type 'Persistence'.ts(2345)

Posted at

Persistenceをどうやって渡せばいい??

firebaseのバージョンを9に上げてから、色々なものが大きく変わりました。。。:frowning2:
そのうちの1つがsetPersistenceメソッド

環境

package.json
"@angular/fire": "7.3.0",
"firebase": "^9.0.0",

コード例

angularfireを使ってるので、少しだけjavascriptだけのコード

Version V8以前

import * as firebase from 'firebase/compat/app';
import { Auth } from '@angular/fire/auth';


constructor(
    private afAuth: Auth,
  ) { }


this.afAuth.setPersistence(firebase.auth.Auth.Persistence.LOCAL);

this.afAuth.setPersistence(firebase.default.auth.Auth.Persistence.LOCAL);

Version V9以降

import { browserLocalPersistence } from 'firebase/auth';
import { Auth } from '@angular/fire/auth';

constructor(
    private afAuth: Auth,
  ) { }

this.afAuth.setPersistence(browserLocalPersistence);

browserLocalPersistence(LOCAL)以外のオプションについては👇の参考をご覧ください:relieved:

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?