getGCMConsents method
Implementation
@override
Future<Map<GoogleConsentType, ConsentStatus>> getGCMConsents() async {
try {
debugPrint('Calling getGCMConsents method...');
final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>('getGCMConsents');
debugPrint('getGCMConsents result type: ${result?.runtimeType}');
if (result == null) {
debugPrint('getGCMConsents result is null');
return {};
}
Map<GoogleConsentType, ConsentStatus> gcmConsents = {};
result.forEach((key, value) {
try {
// Convert the string key to GoogleConsentType enum
final consentType = GoogleConsentType.fromString(key.toString());
// Convert the value (string) to ConsentStatus
if (value is String) {
final consentStatus = ConsentStatus.fromString(value);
gcmConsents[consentType] = consentStatus;
}
} catch (e) {
debugPrint('Error processing GCM consent for key $key: $e');
}
});
debugPrint('Successfully parsed ${gcmConsents.length} GCM consents');
return gcmConsents;
} catch (e) {
debugPrint('Error in getGCMConsents: $e');
debugPrint('Stack trace: ${StackTrace.current}');
return {};
}
}