blaugold / iabtcf_consent_info

Flutter plugin for reading IAB TCF v2.0 user consent information, such as made available through CMP SDKs, like Funding Choices's User Messaging Platform (UMP).
https://pub.dev/packages/iabtcf_consent_info
10 stars 8 forks source link

consentInfo().listen() gets first info, only #7

Open xErik opened 2 years ago

xErik commented 2 years ago

Quick question, consentInfo().listen() seems not to work correctly in my case.

It gets the first consent-info, but when the user adjusts the consent-settings, it gets nothing.

IabtcfConsentInfo.instance.consentInfo().listen((info) {
  print(info);
 });

Adjusting the consent-settings on my mobile, these get actually written as can be seen in my debug logs, but the listener is not updated with these new settings:

D/UserMessagingPlatform( 5131): Action[write]: {"IABTCF_CmpSdkID":300,"IABTCF_CmpSdkVersion":1,"IABTCF_PolicyVersion":2,"IABTCF_gdprApplies":1, ...

Should consentInfo().listen() actually work or is it due to some discrepancies between UMP evolving over time and this library? Am I doing something wrong?

blaugold commented 2 years ago

Thanks for reporting this. listen should work as you expect it to. The plugin listens for changes to the SharedPreferences returned from PreferenceManager.getDefaultSharedPreferences on Android. I'll have to investigate.

xErik commented 2 years ago

Thank you. Another observation is that the call

await IabtcfConsentInfo.instance.currentConsentInfo()

works the first time. But, after updating the consent using Google UMP SDK in Flutter, each subsequent call does not return the changes values. In this case, a restart of the App helps and the previously changed values are returned.

But as I said, it might be that I am doing something wrong. I am also new to App development.] in general.

andreacimino commented 11 months ago

I have the same issue, i have the suspect that the bug is in this line.

Future<BasicConsentInfo?> currentConsentInfo() => consentInfo().first;

While it should be

Future<BasicConsentInfo?> currentConsentInfo() => consentInfo().last;

since the stream is changed.

Guillergood commented 2 months ago

Hello, If you need a quick fix, please replace your iabtcf_consent_info value in pubspec.yaml:

iabtcf_consent_info:    
   git:
      branch: getUpdatedContent
      url: https://github.com/Guillergood/iabtcf_consent_info.git
      path: packages/iabtcf_consent_info