Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 3 additions & 38 deletions source/plugin/Assets/Plugins/Ump/iOS/GADUConsentInformation.h
Original file line number Diff line number Diff line change
@@ -1,58 +1,23 @@
// Copyright 2022 Google LLC. All Rights Reserved.
#import <UserMessagingPlatform/UMPConsentInformation.h>

#import <Foundation/Foundation.h>
#import "GADURequestParameters.h"
#import "GADUUmpTypes.h"

/// Consent status values.
typedef NS_ENUM(NSInteger, GADUConsentStatus) {
kGADUConsentStatusUnknown = 0, ///< Unknown consent status.
kGADUConsentStatusNotRequired = 1, ///< Consent not required.
kGADUConsentStatusRequired = 2, ///< User consent required but not yet obtained.
kGADUConsentStatusObtained =
3, ///< User consent obtained, personalized vs non-personalized undefined.
};

/// State values for whether the user has a consent form available to them. To check whether form
/// status has changed, an update can be requested through
/// requestConsentInfoUpdateWithParameters:completionHandler.
typedef NS_ENUM(NSInteger, GADUFormStatus) {
/// Whether a consent form is available is unknown. An update should be requested using
/// requestConsentInfoUpdateWithParameters:completionHandler.
kGADUFormStatusUnknown = 0,

/// Consent forms are available and can be loaded using [UMPConsentForm
/// loadWithCompletionHandler:].
kGADUFormStatusAvailable = 1,

/// Consent forms are unavailable. Showing a consent form is not required.
kGADUFormStatusUnavailable = 2,
};

/// State values for whether the user needs to be provided a way to modify their privacy options.
typedef NS_ENUM(NSInteger, GADUPrivacyOptionsRequirementStatus) {
/// Requirement unknown.
kGADUPrivacyOptionsRequirementStatusUnknown = 0,
/// A way must be provided for the user to modify their privacy options.
kGADUPrivacyOptionsRequirementStatusRequired = 1,
/// User does not need to modify their privacy options. Either consent is not required, or the
/// consent type does not require modification.
kGADUPrivacyOptionsRequirementStatusNotRequired = 2,
};

/// Utility methods for collecting consent from users.
@interface GADUConsentInformation : NSObject

/// The user's consent status. This value is cached between app sessions and can be read before
/// requesting updated parameters.
@property(readonly, nonatomic) GADUConsentStatus consentStatus;
@property(readonly, nonatomic) UMPConsentStatus consentStatus;

/// Check if the app has finished all the required consent flow and can request ads now.
/// A return value of true means the app can request ads now.
@property(nonatomic, readonly) BOOL canRequestAds;

/// The privacy options requirement status.
@property(nonatomic, readonly) GADUPrivacyOptionsRequirementStatus privacyOptionsRequirementStatus;
@property(nonatomic, readonly) UMPPrivacyOptionsRequirementStatus privacyOptionsRequirementStatus;

/// YES if consent form is available, NO otherwise. An update should be requested using
/// requestConsentInfoUpdateWithParameters.
Expand Down
22 changes: 9 additions & 13 deletions source/plugin/Assets/Plugins/Ump/iOS/GADUConsentInformation.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 Google LLC. All Rights Reserved.

#import "GADUConsentInformation.h"
#import <UserMessagingPlatform/UMPConsentInformation.h>

#import "GADUDebugSettings.h"
#import "GADUDispatch.h"
Expand All @@ -25,13 +24,13 @@ - (instancetype)initWithConsentInformationClientReference:
return self;
}

- (GADUConsentStatus)consentStatus {
__block GADUConsentStatus status;
if (NSThread.isMainThread) {
status = (GADUConsentStatus)UMPConsentInformation.sharedInstance.consentStatus;
- (UMPConsentStatus)consentStatus {
__block UMPConsentStatus status;
if (!NSThread.isMainThread) {
status = UMPConsentInformation.sharedInstance.consentStatus;
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
status = (GADUConsentStatus)UMPConsentInformation.sharedInstance.consentStatus;
status = UMPConsentInformation.sharedInstance.consentStatus;
});
}
return status;
Expand All @@ -49,16 +48,13 @@ - (BOOL)canRequestAds {
return status;
}

- (GADUPrivacyOptionsRequirementStatus)privacyOptionsRequirementStatus {
__block GADUPrivacyOptionsRequirementStatus status;
- (UMPPrivacyOptionsRequirementStatus)privacyOptionsRequirementStatus {
__block UMPPrivacyOptionsRequirementStatus status;
if (NSThread.isMainThread) {
status =
(GADUPrivacyOptionsRequirementStatus)[UMPConsentInformation
.sharedInstance privacyOptionsRequirementStatus];
status = [UMPConsentInformation.sharedInstance privacyOptionsRequirementStatus];
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
status = (GADUPrivacyOptionsRequirementStatus)[UMPConsentInformation.sharedInstance
privacyOptionsRequirementStatus];
status = [UMPConsentInformation.sharedInstance privacyOptionsRequirementStatus];
});
}
return status;
Expand Down