loginAnonymous method
Logs in a user anonymously
Set doNotSendInstallationID
to 'true' in order to prevent the SDK from sending the installationID to the Server.
This option is especially useful if you are running you application on web and you don't have permission to add 'X-Parse-Installation-Id' as an allowed header on your parse-server.
Implementation
Future<ParseResponse> loginAnonymous(
{bool doNotSendInstallationID = false}) async {
forgetLocalSession();
try {
final Uri url = getSanitisedUri(_client, keyEndPointUsers);
const Uuid uuid = Uuid();
final String? installationId = await _getInstallationId();
final ParseNetworkResponse response = await _client.post(
url.toString(),
options: ParseNetworkOptions(headers: <String, String>{
keyHeaderRevocableSession: '1',
if (installationId != null && !doNotSendInstallationID)
keyHeaderInstallationId: installationId,
}),
data: jsonEncode(<String, dynamic>{
'authData': <String, dynamic>{
'anonymous': <String, dynamic>{'id': uuid.v4()}
}
}),
);
return await _handleResponse(
this, response, ParseApiRQ.loginAnonymous, _debug, parseClassName);
} on Exception catch (e) {
return handleException(
e, ParseApiRQ.loginAnonymous, _debug, parseClassName);
}
}