Coder Social home page Coder Social logo

blaugold / iabtcf_consent_info Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 6.0 211 KB

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).

Home Page: https://pub.dev/packages/iabtcf_consent_info

Swift 7.32% Dart 70.70% Objective-C 0.10% Ruby 1.68% Kotlin 8.56% JavaScript 5.54% HTML 4.34% Java 1.75%
flutter plugin iab tcf

iabtcf_consent_info's Introduction

iabtcf_consent_info's People

Contributors

bcyran avatar blaugold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iabtcf_consent_info's Issues

Type cast exception in ConsentInfo.parseRawInfo

A wrong type cast from Null to int causes an exception in the ConsentInfo.parseRawInfo factory.

sdkVersion: rawInfo[_cmpSdkVersionKey] as int

It looks like it is thrown in this line.

Try-catch like below can't catch it and the app stops there, which is critical...

late final ConsentInfo? info;
try {
  info = await IabtcfConsentInfo.instance.currentConsentInfo();
} on Exception catch (e) {
  info = null;
}

I'm not 100% sure in what condition it occurs, but as far as I can see, there's no problem if a GDPR dialog is shown outside EEA using your "user_messaging_platform" plugin with the debug options (geography: DebugGeography.EEA, testDeviceIds: xxxxx) set, and the exception occurs when currentConsentInfo() is executed after the dialog is skipped without the debug options.

E/flutter (18850): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast
E/flutter (18850): #0      new ConsentInfo.parseRawInfo (package:iabtcf_consent_info/iabtcf_consent_info.dart:112:46)
E/flutter (18850): #1      IabtcfConsentInfo._onConsentInfoListen.<anonymous closure> (package:iabtcf_consent_info/iabtcf_consent_info.dart:206:31)
E/flutter (18850): #2      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
E/flutter (18850): #3      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (18850): #4      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (18850): #5      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (18850): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (18850): #7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (18850): #8      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (18850): #9      _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (18850): #10     _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
E/flutter (18850): #11     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (18850): #12     _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (18850): #13     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (18850): #14     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (18850): #15     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (18850): #16     _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (18850): #17     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
E/flutter (18850): #18     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
E/flutter (18850): #19     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (18850): #20     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (18850): #21     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (18850): #22     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (18850): #23     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (18850): #24     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (18850): #25     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (18850): #26     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (18850): #27     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (18850): #28     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (18850): 

gdprApplies remains true after GDPR dialog is shown

gdprApplies in BasicConsentInfo returned by IabtcfConsentInfo.instance.currentConsentInfo() is false if a GDPR dialog has not been opened using package:google_mobile_ads or have been opened outside EEA without the setting of debugGeography: DebugGeography.debugGeographyEea. However, once the dialog is opened with the debug setting, gdprApplies remains true even if the dialog is reopened without the setting.

  1. Dialog has not been opened yet
    • gdprApplies: false
  2. Dialog was opened without debugGeographyEea
    • gdprApplies: false
  3. Dialog was opened with debugGeographyEea
    • gdprApplies: true
  4. Dialog was reopened without debugGeographyEea
    • gdprApplies: true

I'm not sure if it is a bug of this plugin or as per spec of the underlying SDK. Please just close this if it is expected behaviour.

Expose raw consent info

Add BasicConsentInfo.raw to allow access to the raw consent info, provided by the CMP SDK.

Error: The getter 'publisherConsents' isn't defined for the class 'BasicConsentInfo'

I can't seem to access publisherConsents in the return. I can print it but I can't access it? Any ideas? I'm using the demo code.

I'd like to create a wrapper that takes a widget, checks for consent and decides whether the it can load.

import 'package:flutter/material.dart';
import 'package:iabtcf_consent_info/iabtcf_consent_info.dart';

class ConsentGate extends StatefulWidget {
  const ConsentGate({Key? key, required this.child}) : super(key: key);

  final Widget child;

  @override
  State<ConsentGate> createState() => _ConsentGateState();
}

class _ConsentGateState extends State<ConsentGate> {
  BasicConsentInfo? consentInfo;

  @override
  void initState() {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      consentInfo = await _getConsentInfo();
    });
    super.initState();
  }

  Future<BasicConsentInfo?> _getConsentInfo() async {
    BasicConsentInfo? consent =
        await IabtcfConsentInfo.instance.currentConsentInfo();

    setState(() {
      consentInfo = consent;
    });

    return consent;
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Text(consentInfo.toString());
  }
}

I'd like to have a conditional check in the build but I can't access the data. I can see the data being printed but I'm unsure how to access it.

Screenshot 2023-03-20 at 13 27 17

consent info is now returning an invalid value

Sorry, relative beginner developer here but hopefully i can provide the info you need.

My implementation had been working fine... However a couple of days ago my calls retrieve .currencyConsentInfo() started failing due to an out of range error. I guess something about the values the google UMP outputs must have changed?

My Crashlytics report is below incase it helps.

/flutter (17455): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (17455): RangeError (index): Invalid value: Not in inclusive range 0..9: 10
I/flutter (17455): #0 _Array.[] (dart:core-patch/array.dart:10:36)
I/flutter (17455): #1 _parseDataUsagePurposeBinaryString. (package:iabtcf_consent_info/iabtcf_consent_info.dart:290:45)
I/flutter (17455): #2 MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
I/flutter (17455): #3 ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
I/flutter (17455): #4 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
I/flutter (17455): #5 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
I/flutter (17455): #6 new List.of (dart:core-patch/array_patch.dart:47:28)
I/flutter (17455): #7 ListIterable.toList (dart:_internal/iterable.dart:214:7)
I/flutter (17455): #8 _parseDataUsagePurposeBinaryString (package:iabtcf_consent_info/iabtcf_consent_info.dart:291:10)
I/flutter (17455): #9 _ValueExt.let (package:iabtcf_consent_info/iabtcf_consent_info.dart:345:35)
I/flutter (17455): #10 parseRawConsentInfo.parseDataUsagePurposes (package:iabtcf_consent_info/iabtcf_consent_info.dart:255:26)
I/flutter (17455): #11 parseRawConsentInfo (package:iabtcf_consent_info/iabtcf_consent_info.dart:263:22)
I/flutter (17455): #12 _Ma

IabtcfConsentInfoPlugin.sendConsentInfo

Do you know why and how to fix?

Version de l'OS : android13
Modèle : Samsung Galaxy S23

Fatal Exception: java.lang.NullPointerException:
       at com.terwesten.gabriel.iabtcf_consent_info.IabtcfConsentInfoPlugin.sendConsentInfo(IabtcfConsentInfoPlugin.java:18)
       at com.terwesten.gabriel.iabtcf_consent_info.IabtcfConsentInfoPlugin.sharedPreferencesListener$lambda$0(IabtcfConsentInfoPlugin.java:5)
       at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:637)
       at android.app.SharedPreferencesImpl$EditorImpl.lambda$notifyListeners$0$SharedPreferencesImpl$EditorImpl(SharedPreferencesImpl.java:643)
       at android.app.-$$Lambda$SharedPreferencesImpl$EditorImpl$3CAjkhzA131V3V-sLfP2uy0FWZ0.run(:4)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:236)
       at android.app.ActivityThread.main(ActivityThread.java:8057)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

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

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.