xamarin / GoogleApisForiOSComponents

MIT License
225 stars 162 forks source link

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

Open FANMixco opened 1 year ago

FANMixco commented 1 year ago

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 commented 1 year ago

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:

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.

BenEastpoint commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

FANMixco commented 1 year ago

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

rolfbjarne commented 1 year ago

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 David.Ortinau@microsoft.com.

FANMixco commented 1 year ago

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 David.Ortinau@microsoft.com.

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 commented 1 year ago

@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 commented 1 year ago

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

pboisso commented 1 year ago

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 commented 11 months ago

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 commented 10 months ago

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

FANMixco commented 10 months ago

@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 commented 10 months ago

@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 commented 10 months ago

@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 commented 10 months ago

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

emiliobongiorno commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 7 months ago

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 commented 7 months ago

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.