void signWithGoogle(
BuildContext context,
WidgetRef? ref,
) async {
try {
final GoogleSignIn googleSignIn = GoogleSignIn();
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn();
String? deviceToken = await FirebaseMessaging.instance.getToken();
UserModel.User user = UserModel.User(
id: '',
uniqueId: '',
displayName: googleSignInAccount!.displayName!.toString(),
email: googleSignInAccount.email,
mobile: 0,
profilePicture: googleSignInAccount.photoUrl != ''
? googleSignInAccount.photoUrl
: profilePic,
followers: [],
following: [],
token: '',
deviceToken: deviceToken!,
createdAt: '',
);
http.Response res = await http.post(
Uri.parse('$url/api/signup'),
body: user.toJson(),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8",
},
);
if (context.mounted) {
httpErrorHanding(
res: res,
context: context,
onSuccess: () async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString(
'x-access-token', jsonDecode(res.body)['token']);
ref!.read(userProvider.notifier).updateUser(res.body);
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => BottomBar(data: 0),
),
);
},
);
}
} catch (e) {
showSnackbar(context, e.toString());
}
}
}
这是我的注册码,当我尝试将 FCM 令牌存储在模拟器中时,它可以正常工作,但在我的真实设备上却显示错误: “主题同步或令牌检索因硬故障异常而失败:TOO_MANY_REGISTRATIONS。不会重试该操作。在真实设备中”
请帮我解决这个问题