Skip to content

Commit e5a5fb3

Browse files
committed
Add auth
1 parent 8f55e31 commit e5a5fb3

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

sjfirebase/jinterface/auth.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from typing import Callable
2+
3+
from jnius import PythonJavaClass, java_method
4+
5+
__all__ = ("AuthStateListener", "IdTokenListener")
6+
7+
8+
class AuthStateListener(PythonJavaClass):
9+
__javainterfaces__ = ["com/google/firebase/auth/FirebaseAuth$AuthStateListener"]
10+
__javacontext__ = "app"
11+
12+
def __init__(self, callback):
13+
self.callback = callback
14+
15+
@java_method("(Lcom/google/firebase/auth/FirebaseAuth;)V")
16+
def onAuthStateChanged(self, auth):
17+
self.callback(auth)
18+
19+
20+
class IdTokenListener(PythonJavaClass):
21+
__javainterfaces__ = ["com/google/firebase/auth/FirebaseAuth$IdTokenListener"]
22+
__javacontext__ = "app"
23+
24+
def __init__(self, callback):
25+
self.callback = callback
26+
27+
@java_method("(Lcom/google/firebase/auth/FirebaseAuth;)V")
28+
def onIdTokenChanged(self, auth):
29+
self.callback(auth)

0 commit comments

Comments
 (0)