Created
January 7, 2022 22:15
-
-
Save Hesamedin/6f0ab09fe58b2d019bf9b9974d896342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> storePushNotificationToken(String userId, String token) async { | |
final batch = _firestore.batch(); | |
final pushTokenRef = _firestore.collection(FirestoreCollection.pushToken.path).doc(userId); | |
batch.set( | |
pushTokenRef, | |
{'userId': userId, 'token': token}, | |
SetOptions(merge: true), | |
); | |
final pushTokenTokensRef = pushTokenRef.collection(FirestoreCollection.pushTokenTokens.path).doc(); | |
batch.set( | |
pushTokenTokensRef, | |
{'token': token, 'valid': true}, | |
SetOptions(merge: true), | |
); | |
batch.commit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment