initialize method
Implementation
Future initialize(Getter<BuildContext?> context, Stream<AuthUserProfile?> userChanges) async {
userChanges.listen((user) {
if (user == null) {
return;
}
if (_auth?.uid != user.fbUser?.uid) {
_auth = user.fbUser;
if (user.fbUser != null && _pendingToken != null && context() != null) {
doSendPushToken(context()!, _pendingToken!);
_pendingToken = null;
} else {
log.info("No pending token to send");
}
}
}, cancelOnError: false).watch(this);
_platform.pushTokens.auto(this, onItem: (token) {
if (context() != null) {
_withNewToken(context()!, token);
}
});
await _platform.initialize(convertMessage);
/// Don't await this one, because failed permissions will just cause a hang
_platform.requestPermissions().then((value) => registerFcmToken(context));
}