Giter VIP home page Giter VIP logo

skyost / flutterfundingchoices Goto Github PK

View Code? Open in Web Editor NEW
8.0 5.0 10.0 301 KB

The Flutter implementation of Funding Choices, a Google service that allows to request user consent for personalized ads in AdMob.

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

License: MIT License

Kotlin 27.72% Swift 21.39% Objective-C 4.00% Dart 33.90% Ruby 12.99%
ads admob flutter dart funding-choices

flutterfundingchoices's Introduction

Flutter Funding Choices

Flutter Funding Choices is an unofficial Flutter implementation of Funding Choices, a Google service that allows to request user consent for personalized ads in AdMob.

Prerequisites

You must have linked your FundingChoices account to your Admob account. See this documentation on Google Support.

Installation

Android

Your app must use Android Embedding V2. Also, you need to add an app id in your AndroidManifest.xml (in the application tag) :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="fr.skyost.example">

   <application
       <!--
         Some attributes here...
        -->
    >
       <meta-data
           android:name="com.google.android.gms.ads.APPLICATION_ID"
           android:value="YOUR-APP-ID"/>
       <!--
         Activities, ...
        -->
   </application>

</manifest>

You can obtain your app ID by following these instructions.

iOS

You need to add an app id in your Info.plist :

<key>GADApplicationIdentifier</key>
<string>YOUR-APP-ID</string>

You can obtain your app ID by following these instructions. You may also need to handle Apple's App Tracking Transparency message by putting this in your Info.plist :

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

Feel free to configure the message as you want.

How to use

There are three methods :

  • FlutterFundingChoices.requestConsentInformation() : Allows to get current user consent information (whether you need to show the consent form, whether the user wants personalized ads, ...).
  • FlutterFundingChoices.showConsentForm() : Loads and shows the consent form. You must check first that there is a consent form (with isConsentFormAvailable on the returned object of the previous method).
  • FlutterFundingChoices.reset() : Resets the consent information.

You typically want to use it like this on Android :

@override
void initState() {
  super.initState();
  WidgetsBinding.instance.addPostFrameCallback((_) async {
    ConsentInformation consentInfo = await FlutterFundingChoices.requestConsentInformation();
    if (consentInfo.isConsentFormAvailable && consentInfo.consentStatus == ConsentStatus.required) {  
      await FlutterFundingChoices.showConsentForm();
      // You can check the result by calling `FlutterFundingChoices.requestConsentInformation()` again !
    }
  });
}

Contributions

You have a lot of options to contribute to this project ! You can :

flutterfundingchoices's People

Contributors

andre-arsenault avatar andre-lbc avatar skyost avatar tnorbury avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flutterfundingchoices's Issues

Ability to use the setDebugGeography() method

Can we have access to the setDebugGeography() method to test how our app react?

I saw that it's available on the Android part: https://developers.google.com/admob/ump/android/quick-start

It can be used for non-EU devs to test their app in EU but it is also useful for EU devs to test their app in non-EU countries (like me!).

Due to some bad handling, users of my app outside of EU are not seeing any ads and my analytics don't work because I messed up with the funding choices. They are enabled only if you accept the Funding Choices dialog, but it is not shown outside EU I think.
I would like to verify this and correct it but I can't really test it since I'm in EU! 😅

Android build failure after updating to Kotlin Gradle plugin 1.8.21

Describe the bug
App no longer builds with FlutterFundingChoices after updating to Android Gradle plugin version 7.4.2 via Android Studio.

To Reproduce
Steps to reproduce the behavior:

  1. Take an existing Flutter Android app that used to work and update its android/build.gradle class path 'com.android.tools.build:gradle:' depdency to 7.4.2 (in my case it was 7.2.1 previously).
  2. flutter build apk

Expected behavior
App should build successfully.

Log

% flutter build apk --debug --flavor live                                           


FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':flutter_funding_choices' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Running Gradle task 'assembleLiveDebug'...                          5.9s
Gradle task assembleLiveDebug failed with exit code 1

Flutter doctor output:

% flutter doctor -v
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-x64, locale en-US)
    • Flutter version 3.10.0 on channel stable at /Users/andre/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (8 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4)
    • Android SDK at /Users/andre/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0-rc4
    • ANDROID_SDK_ROOT = /Users/andre/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (1 available)
    • macOS (desktop) • macos • darwin-x64 • macOS 13.3.1 22E772610a darwin-x64

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Can't find the import

Im trying to use the package, but after I add it, I can't find the import, any fix for this?

Fatal Error on iOS

Describe the bug
A Funding Choices message appears on Android but not on iOS. I created the same message on the FC website for both platforms. On iOS, when trying to debug, I created a function to reset and then ask for consent again as follows:

Future<void> resetConsentOptions() async { try { await FlutterFundingChoices.reset(); ConsentInformation consentInfo = await FlutterFundingChoices.requestConsentInformation(); if (consentInfo.isConsentFormAvailable && consentInfo.consentStatus == ConsentStatus.REQUIRED) { await FlutterFundingChoices.showConsentForm(); } } catch (e) { // Error Snackbar } }

This crashes the app with the following message in the log:
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file flutter_funding_choices/SwiftFlutterFundingChoicesPlugin.swift, line 16

To Reproduce
Steps to reproduce the behaviour:
Described above

Desktop (please complete the following information):

  • MacOS Big Sur 11.0.1

Smartphone (please complete the following information):

  • iPhone 12 Pro Max iOS 14.3 Simulator

IOS build error: Parse Issue: Module flutter_funding_choices not found

Describe the bug
Just tried to build my app for IOS in dev mode and it returns me the error.
The file file it opens up on clicking on the error is: GeneratedPluginRegistrant.m

To Reproduce
Steps to reproduce the behavior:

  1. Open up app in Xcode
  2. Click on the "play" button for building it
  3. Wait for build
  4. See error

Expected behavior
Build successfully and launch app in emulator
Screenshots
Bildschirmfoto 2021-07-13 um 00 54 28

Desktop:

  • OS: Mac OS Catalina
  • Version: 10.15.7

Smartphone:

  • Device: iPhone 12 (Emulator)
  • OS: IOS
  • Version: NA

Additional context
There is a chance that I've messed configurations or so up, as this is my first time building for IOS.
My min IOS target or what it's called is 12.0.
Notice: I ran also flutter build ipa before, which completed without errors, which is kinda odd that Xcode can't build it.

Is it possible to use Funding Choices for Crashlytics and Analytics?

Hello, thank you for your package ! Funding choices is not really clear in my head and I have some questions.

This package seems quite good for personalized and non-personalized ads, but in my understanding (which may be wrong), the funding choices allow to ask for way more than that, e.g. : "performance measurement of advertising and content" seems to allow me to use Firebase Analytics (measure performance of content), "Develop and improve products" + "Provide security, prevent fraud and debug" seems to be related with Crashlytics since crash reports may help me improve my product and debug it... Am I right?

Based on this, I would need to have more informations from the package about the consent the user gives :

  1. Am I allowed to use Crashlytics?
  2. Am I allowed to use Analytics?

If not with Funding Choices, how do you deal with these authorization steps? Having one more dialog seems overkill with all the things the Funding Choices asks...

Question about how the consent dialog is triggered

I have tested this using a VPN to simulate execution if I were in the EU region, and it works. My question is regarding the case when an EU citizen is outside the EU region. From what I understand, GDPR continues to apply to him/her. Is this covered by this library (and Funding Choices, in general)? Thanks.

consentInfo always returns ConsentStatus.OBTAINED

Describe the bug
I'm testing the consent dialog for Android on my debug android device to see the concent dialog showing up
but consentInfo always returns ConsentStatus.OBTAINED

To Reproduce
Steps to reproduce the behavior:
1.

await funding.FlutterFundingChoices.reset();

set debugGeography: funding.DebugGeography.DEBUG_GEOGRAPHY_EEA
set test devices id testDevicesHashedIds: ["your test device id"]

example:

funding.ConsentInformation consentInfo = await funding.FlutterFundingChoices .requestConsentInformation( debugGeography: funding.DebugGeography.DEBUG_GEOGRAPHY_EEA, tagForUnderAgeOfConsent: true, testDevicesHashedIds: [ "your test device id",
2. get responce

funding.ConsentInformation consentInfo = await .....
3. check consentInfo.consentStatus ---> it's always 3 ( /// Consent has been obtained for this user.static const int OBTAINED = 3;)

Expected behavior
consentInfo.consentStatus should be 2 ----> funding.ConsentStatus.REQUIRED_ANDROID

Always returning ConsentType.UNKNOWN

FlutterFundingChoices.requestConsentInformation() always returns ConsentInformation with ConsentType.UNKNOWN
no matter the choice chosen by the user. But when we choose do not consent the ads doesn't load at all.

After searching for the issue I found this https://www.reddit.com/r/adops/comments/ifh6n9/anybody_using_google_funding_choices_for_gdpr_cmp

I would like to know if you faced a similar problem when you implemented this plugin for your apps and if so how did you solve it.

Update UMP SDK to latest 2.0.0 version

Hi,
There were same changes to AdMob & AdSense program policies:
link

Is this SDK able to handle this changes ? thank you
I see error 3.2 (mentioned in the link above) in my admob console

I also noticed there is new version of UMP SDK available:
link

After adding, can't run app on iOS Simulator M1

Hi, after adding this package, I can't run my app on my iOS simulator on an M1 Mac, getting this error:

 /Users/armandojimenez/Development/Flutter/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_funding_choices-0.2.0/ios/Classes/SwiftFlutterFundingChoicesPlugin.swift:3:8: error: no such module 'UserMessagingPlatform'
    import UserMessagingPlatform
           ^
78
    Command CompileSwift failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete

Unhandled exception

Upgraded to 1.0.0, getting this error:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
#0      ListBase.firstWhere (dart:collection/list.dart:132:5)
#1      ConsentStatus.fromValue
flutter_funding_choices.dart:100
#2      FlutterFundingChoices.requestConsentInformation
flutter_funding_choices.dart:37
<asynchronous suspension>

Using default example.

Issue during the upgrade to 0.3.0+1

Hello, I have tried to use your FlutterFundingChoice package and during the build the here under errors appears (and disappear when the I remove flutter_funding_choices: ^0.3.0+1 from dependencies).
As I don't know how to solve them, could you please tell me if it could be related to the package itself or come from a mistake in my configuration.
Thanks in advance for your help and assistance.

Console log:

<module-includes>:1:9: note: in file included from <module-includes>:1:
    #import "Headers/UserMessagingPlatform.h"
            ^
/build/ios/Debug-iphonesimulator/XCFrameworkIntermediates/GoogleUserMessagingPlatform/UserMessagingPlatform.framework/Headers/UserMessagingPlatform.h:1:9: note: in file included from /build/ios/Debug-iphonesimulator/XCFrameworkIntermediates/GoogleUserMessagingPlatform/UserMessagingPlatform.framework/Headers/UserMessagingPlatform.h:1:
    #import <UserMessagingPlatform/UMPConsentForm.h>
            ^
/build/ios/Debug-iphonesimulator/XCFrameworkIntermediates/GoogleUserMessagingPlatform/UserMessagingPlatform.framework/Headers/UMPConsentForm.h:20:1: warning: conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull'
    - (nullable instancetype)init NS_UNAVAILABLE;
    ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/include/objc/NSObject.h:63:1: note: previous declaration is here
    - (instancetype)init
    ^
    Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_funding_choices-0.3.0+1/ios/Classes/SwiftFlutterFundingChoicesPlugin.swift:19:266: error: cannot convert value of type 'UMPDebugGeography' to expected argument type '[Int]'
                requestConsentInformation(tagForUnderAgeOfConsent: arguments["tagForUnderAgeOfConsent"] as! Bool, testDevicesHashedIds: (arguments["testDevicesHashedIds"] as? [String]) ?? [], debugGeography: (arguments["debugGeography"] as? [Int]) ?? UMPDebugGeography.disabled, result: result)
                                                                                          ^
    Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_funding_choices-0.3.0+1/ios/Classes/SwiftFlutterFundingChoicesPlugin.swift:37:39: error: cannot assign value of type '[Int]' to type 'UMPDebugGeography'
                debugSettings.geography = debugGeography

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.