Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Will Xamarin.Google.iOS.UserMessagingPlatform be ever updated and documented? It has been almost 4 years since the last update. #628

Open
FANMixco opened this issue Sep 19, 2023 · 22 comments

Comments

@FANMixco
Copy link

FANMixco commented Sep 19, 2023

Fellows, it seems the last time this library (Xamarin.Google.iOS.UserMessagingPlatform) was in 2020, and several Devs are facing issues. Also, there is no document of how to use it:
https://www.nuget.org/packages/Xamarin.Google.iOS.UserMessagingPlatform

image

You can see questions concerns in different places like here:

Currently, only the Android lib is being updated from time to time:
https://www.nuget.org/packages/Xamarin.Google.UserMessagingPlatform

image

Any additional thoughts, @mikeks?

@FANMixco
Copy link
Author

Bing Chat provided me this answer of how use it, but I'm not sure it's workable. @mikeks would be a better tester than me.

Thank you for clarifying your question. UserMessagingPlatform is a library that helps you display GDPR consent messages to your app users in the European Economic Area (EEA) or the UK¹. It is part of the Google Mobile Ads SDK and works with AdMob and other Google advertising products².

To use UserMessagingPlatform in your iOS app, you need to follow these steps:

  • Install the Xamarin.Google.iOS.UserMessagingPlatform NuGet package in your app project³.
  • Add the User Messaging Platform framework to your Xcode project⁴.
  • Initialize the Google Mobile Ads SDK in your app delegate's FinishedLaunching method.
  • Request consent information from the User Messaging Platform API using the ConsentInformation class.
  • Check if the user is located in the EEA or the UK using the IsRequestLocationInEeaOrUnknown property.
  • If yes, load and display a consent message using the ConsentForm class.
  • Handle the user's consent choice using the ConsentStatus enum.

Here is an example of how to use UserMessagingPlatform in your iOS app:

using Google.MobileAds;
using Google.MobileAds.Consent;
using UIKit;

namespace MyApp
{
    public class AppDelegate : UIApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Initialize Google Mobile Ads SDK
            MobileAds.SharedInstance.Start(null);

            // Request consent information
            ConsentInformation.SharedInstance.RequestConsentInfoUpdate(new string[] { "pub-0[1](https://cookieinformation.com/resources/blog/is-your-mobile-app-gdpr-compliant/)[2](https://www.appknox.com/resources/guides/make-your-mobile-app-compliant-to-gdpr)[3](https://support.google.com/admob/answer/10113207?hl=en)[4](https://stackoverflow.com/questions/50486708/how-to-add-gdpr-consent-dialog-in-app-and-gdpr-related-confusions)56789012345" }, (error) =>
            {
                if (error == null)
                {
                    // Check user location
                    if (ConsentInformation.SharedInstance.IsRequestLocationInEeaOrUnknown)
                    {
                        // Load consent message
                        ConsentForm consentForm = new ConsentForm();
                        consentForm.Load((loadError) =>
                        {
                            if (loadError == null)
                            {
                                // Show consent message
                                consentForm.Show((dismissError, userPrefersAdFree) =>
                                {
                                    if (dismissError == null)
                                    {
                                        // Handle user choice
                                        switch (ConsentInformation.SharedInstance.ConsentStatus)
                                        {
                                            case ConsentStatus.NonPersonalized:
                                                // Show non-personalized ads
                                                break;
                                            case ConsentStatus.Personalized:
                                                // Show personalized ads
                                                break;
                                            default:
                                                // No consent given, do not show ads
                                                break;
                                        }
                                    }
                                });
                            }
                        });
                    }
                }
            });

            return true;
        }
    }
}

I hope this helps you with your app development. If you have any other questions, please feel free to ask. 😊

Source: Conversation with Bing, 9/18/2023
(1) GDPR compliance for mobile apps: A checklist in 7 steps. https://cookieinformation.com/resources/blog/is-your-mobile-app-gdpr-compliant/.
(2) Guide: Make Your Mobile App Compliant to GDPR - Appknox. https://www.appknox.com/resources/guides/make-your-mobile-app-compliant-to-gdpr.
(3) Create GDPR messages for apps - Google AdMob Help. https://support.google.com/admob/answer/10113207?hl=en.
(4) How to add GDPR consent dialog in app and GDPR related confusions. https://stackoverflow.com/questions/50486708/how-to-add-gdpr-consent-dialog-in-app-and-gdpr-related-confusions.

@FANMixco FANMixco changed the title Will Xamarin.Google.iOS.UserMessagingPlatform be ever updated? Will Xamarin.Google.iOS.UserMessagingPlatform be ever updated and documented? Sep 19, 2023
@BenEastpoint
Copy link

Hi @FANMixco, I have a .NET MAUI project running on .NET 7. I've implemented GDPR consent forms on Android using Xamarin.Google.UserMessagingPlatform, but have struggled to find anything for iOS. I tried to follow the guide above but "using Google.MobileAds.Consent;" returns:

"The type or namespace name 'Consent' does not exist in the namespace 'Google.MobileAds' (are you missing an assembly reference?)"

And as a result none of the code below that point works.

I have the "Xamarin.Google.iOS.UserMessagingPlatform" nuget package installed.

Do you have any idea where I'm going wrong? Or is the package just not compatible with .NET MAUI?.

@FANMixco
Copy link
Author

Hi @FANMixco, I have a .NET MAUI project running on .NET 7. I've implemented GDPR consent forms on Android using Xamarin.Google.UserMessagingPlatform, but have struggled to find anything for iOS. I tried to follow the guide above but "using Google.MobileAds.Consent;" returns:

"The type or namespace name 'Consent' does not exist in the namespace 'Google.MobileAds' (are you missing an assembly reference?)"

And as a result none of the code below that point works.

I have the "Xamarin.Google.iOS.UserMessagingPlatform" nuget package installed.

Do you have any idea where I'm going wrong? Or is the package just not compatible with .NET MAUI?.

Hi @BenEastpoint, I'm the wrong candidate for your question. I don't develop for iOS. I opened the question since several people brought the same question to StackOverflow to my Android's example. I would say that as I raised in this ticket, the lib might be incompatible since as you could read in this question, the last time it was updated it was several years ago. You can check the contributors of this repo and asked them.

@tipa
Copy link

tipa commented Nov 3, 2023

I agree that Microsoft should provide bindings for this component. It's one of the core components for iOS developers and having them available would make the .NET iOS platform more attractive.
I have copied and fixed the bindings myself - tested with Mobile Ads SDK 10.12.0 & UMP SDK 2.1.0:
Google.MobileAds.zip

To use it, you need to download the Objective-C package from here and copy the framework folders into the project.
I am sure there are many errors with my bindings and I have commented out a lot of code that I personally don't need so again, it would be great if proper bindings could be provided from Microsoft.

@FANMixco
Copy link
Author

Any thoughts @rolfbjarne? I get frequent questions about this topic and I don't even own a mac.

@FANMixco
Copy link
Author

Do you know if this project is still alive @pjcollins?

@rolfbjarne
Copy link
Member

Any thoughts @rolfbjarne? I get frequent questions about this topic and I don't even own a mac.

That's a question for our PM (CC @davidortinau) - or you could contact him at [email protected].

@FANMixco
Copy link
Author

Any thoughts @rolfbjarne? I get frequent questions about this topic and I don't even own a mac.

That's a question for our PM (CC @davidortinau) - or you could contact him at [email protected].

Thank you, @rolfbjarne. @tipa or @BenEastpoint, can you contact @davidortinau? This topic is outside my scope since I don't even own a mac.

@pboisso
Copy link

pboisso commented Nov 23, 2023

@tipa thanks for sharing your bindings, this is very useful. Looks like those are for .Net Maui. Working on converting them for Xamarin Forms as we are still running Forms in prod at this time. Maui is a work in progress on our side. Have you successfully ran them these bindings with Forms?

@tipa
Copy link

tipa commented Nov 23, 2023

No those bindings are not for Maui. I am using neither MAUI nor Forms, I am using "vanilla" .NET 8 for iOS

@pboisso
Copy link

pboisso commented Nov 23, 2023

Oh I see. Perfect, will try to figure out the Xamarin way from them then. Thanks again, this is a very good starting point. Will provide an update and contribute if we make it happen.

@FANMixco
Copy link
Author

Any comments @davidortinau? It seems the project is kind of death and no one is providing any input. If the project is dead, perhaps, it will be a good idea to achieve it or add some comments. Thanks.

@alexmartinezm
Copy link

Any updates on this? It's very frustrating to deal with these kind of issues on a framework backed and supported by Microsoft.

@FANMixco
Copy link
Author

FANMixco commented Jan 11, 2024

@davidortinau?

Did you consider reaching out by email to @davidortinau? I didn't and won't do it since it doesn't affect me. I'm not an iOS developer.

@alexmartinezm
Copy link

@davidortinau?

Did you consider reaching out by email to @davidortinau? I didn't and won't do it since it doesn't affect me. I'm not an iOS developer.

I'd like to clarify that my intention is not to seek direct individual contact, but rather to direct attention to this GitHub issue and Microsoft.

@FANMixco
Copy link
Author

FANMixco commented Jan 11, 2024

@davidortinau?

Did you consider reaching out by email to @davidortinau? I didn't and won't do it since it doesn't affect me. I'm not an iOS developer.

I'd like to clarify that my intention is not to seek direct individual contact, but rather to direct attention to this GitHub issue and Microsoft.

@alexmartinezm, I don't think that if you and the affected person don't contact @davidortinau directly, neither @microsoft nor his team will do anything about it, as it is not considered a major issue and only affects a few people. This is pretty obvious at this point. It's been almost 4 years since the last lib update and the drop of Visual Studio for Mac support just confirms Microsoft interest about iOS support. In my case, I'm unsubscribing from this topic. This is not my fight since I don't code for iOS. Good luck.

@FANMixco
Copy link
Author

FANMixco commented Jan 11, 2024

I left a tweet in X if anyone else wants to give it a try:
https://twitter.com/FedeStories/status/1745586163157537025

image

Here you have his direct X if anyone else dares to reach @davidortinau:
https://twitter.com/davidortinau

@FANMixco FANMixco changed the title Will Xamarin.Google.iOS.UserMessagingPlatform be ever updated and documented? Will Xamarin.Google.iOS.UserMessagingPlatform be ever updated and documented? It has been almost 4 years since the last update. Jan 12, 2024
@emiliobongiorno
Copy link

Is there any update on this?
This is very important for developers that need to use Admob on iOS using MAUI since the new RGPD requirements for user concent. Is a blocking issue since January 16 2024, and I can't find any solution for iOS yet.

@FANMixco
Copy link
Author

FANMixco commented Mar 4, 2024

Is there any update on this? This is very important for developers that need to use Admob on iOS using MAUI since the new RGPD requirements for user concent. Is a blocking issue since January 16 2024, and I can't find any solution for iOS yet.

Did you consider to tweet @davidortinau?
https://twitter.com/davidortinau

@mikeks
Copy link

mikeks commented Mar 27, 2024

Bing Chat provided me this answer of how use it, but I'm not sure it's workable. @mikeks would be a better tester than me.

The code from Bing Chat is outdated, but I was able to compile it with some changes. I didn't test it yet, I will update this when I test the code.

Corrected code:

			var requestParameters = new RequestParameters();
			requestParameters.TagForUnderAgeOfConsent = false;

#if DEBUG
			requestParameters.DebugSettings = new DebugSettings
			{
				Geography = DebugGeography.Eea
			};
#endif

			ConsentInformation.SharedInstance.RequestConsentInfoUpdate(requestParameters, (error) =>
			{
				if (error == null)
				{
					consentStatus = ConsentInformation.SharedInstance.ConsentStatus;
					// Check user location
					if (consentStatus == ConsentStatus.Unknown
					|| consentStatus == ConsentStatus.Required) // IsRequestLocationInEeaOrUnknown
					{
						// Load consent message
                                                ConsentForm.Load((consentForm, loadError) =>
                                                {
	                                                if (loadError == null)
	                                                {
		                                                // Show consent message
		                                                consentForm.Present(viewController);
	                                                }
                                                });
					}
				}
			});

@FANMixco
Copy link
Author

Hey @mjbond-msft, @Redth, @dalexsoto, do you know if this repo will be ever updated or is it a dead project? It seems almost 4 years since its last update and @davidortinau has never replied. If you plan to stop its development, perhaps, you can archive it and deprecate it to avoid more confusion. Thank you.

@FANMixco
Copy link
Author

FANMixco commented Apr 14, 2024

Hey @mikeks, if you were able to fix the code, perhaps, you could provide the updated one here. It will be useful for everyone who codes for iOS (not my case). Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants