getAnonymousId method
Returns the anonymousId from the cache.
This Generates an anonymous id if one does not exist.
This is used to identify the user in the AppFit dashboard.
This checks to see if a userId exists, if it does not, it will generate an anonymous id.
Implementation
Future<String?> getAnonymousId() async {
final sharedPreferences = await SharedPreferences.getInstance();
final currentId =
sharedPreferences.getString(_AppFitCacheKey.anonymousId.name);
if (currentId != null) return currentId;
// If we dont have an anonymousId, we need to generate one.
final id = const Uuid().v4();
await sharedPreferences.setString(_AppFitCacheKey.anonymousId.name, id);
return id;
}