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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the Google Admob Module in Titanium.

Interested in contributing? Fork and submit your PR :)

## Full sample app

This is a [full sample app](https://github.com/Astrovic/ti.admob-sample-app) to test Google Admob SDK in a Titanium SDK app using the [ti.admob](https://github.com/tidev/ti.admob/tree/master/ios) (iOS) and [ti.android.admob](https://github.com/deckameron/Ti.Android.Admob) (android) modules

## Issues

Report issues to [TiSlack](https://slack.tidev.io/).
Expand Down
74 changes: 72 additions & 2 deletions apidoc/Admob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,21 @@ properties:
type: Number
summary: Geography appears as not in EEA for debug devices.
permission: read-only
value: 3 # FIXME: 2 on iOS, 3 on Android
value: 2
deleted:
since: "8.0.0"

- name: DEBUG_GEOGRAPHY_REGULATED_US_STATE
type: Number
summary: Geography appears as in a regulated US State for debug devices.
permission: read-only
value: 3

- name: DEBUG_GEOGRAPHY_OTHER
type: Number
summary: Geography appears as in a region with no regulation in force.
permission: read-only
value: 4

- name: debugIdentifiers
type: Array<String>
Expand Down Expand Up @@ -305,12 +319,15 @@ properties:

- name: SIMULATOR_ID
type: String
summary: The deviceId for emulators to be used with <Modules.Admob.View.testDevices> property
summary: The deviceId for emulators to be used with <Modules.Admob.View.testDevices> property. Deleted from 8.0.0
permission: read-only
platforms: [android, iphone, ipad]
deprecated:
since: "7.0.0"
notes: Simulators are already in test mode by default.
deleted:
since: "8.0.0"
notes: Simulators are already in test mode by default.

- name: TRACKING_AUTHORIZATION_STATUS_NOT_DETERMINED
type: Number
Expand Down Expand Up @@ -455,6 +472,16 @@ methods:
platforms: [iphone, ipad]
since: "6.3.0"

- name: canRequestAds
returns:
type: Boolean
summary: Indicates whether the SDK has gathered consent aligned with the app’s configured messages.
description: |
Indicates whether the SDK has gathered consent aligned with the app’s configured messages.
Returns NO until `requestConsentInfoUpdateWithParameters()` is called.
platforms: [iphone, ipad]
since: "8.0.0"

- name: canShowAds
returns:
type: Boolean
Expand All @@ -469,6 +496,35 @@ methods:
platforms: [iphone, ipad]
since: "6.3.0"

- name: isPrivacyOptionsRequired
returns:
type: Boolean
summary: Check privacy options requirement status.
description: |
Check privacy options requirement status. This method should only be called after
`Admob.requestConsentInfoUpdateWithParameters()`, otherwise it returns value defaults to
the previous session’s value or `false`.
platforms: [iphone, ipad]
since: "8.0.0"

- name: presentPrivacyOptionsForm
summary: Presents a privacy options form if `Admob.isPrivacyOptionsRequired()` is `true`.
description: |
Presents a privacy options form if `Admob.isPrivacyOptionsRequired()` is `true`.
This method should only be called in response to a user input to request a privacy options form
to be shown. The privacy options form is preloaded by the SDK automatically when a form becomes
available. If no form is preloaded, the SDK will invoke the completionHandler on the next run loop,
but will asynchronously retry to load one. If viewController is nil, uses the top view controller
of the application’s main window.
platforms: [iphone, ipad]
since: "8.0.0"
parameters:
- name: callback
type: Callback<presentPrivacyOptionsFormCallback>
summary: Async callback function to invoke when done
optional: false


- name: requestConsentInfoUpdateForPublisherIdentifiers
returns:
type: void
Expand Down Expand Up @@ -692,6 +748,20 @@ objects:
permission: read-only
constants: Modules.Admob.CONSENT_STATUS_*

- name: presentPrivacyOptionsFormCallback
summary: Simple object passed to the callback used in <Modules.Admob.presentPrivacyOptionsForm>
platforms: [iphone, ipad]
properties:
- name: success
type: Boolean
summary: Check if received a valid response
optional: true

- name: error
type: String
summary: the error message if the privacy options form fails
optional: false

- name: RequestConsentInfoOptions
summary: simple object passed to the <Modules.Admob.requestConsentInfoUpdateForPublisherIdentifiers> method
platforms: [android]
Expand Down
6 changes: 6 additions & 0 deletions ios/Classes/TiAdmobModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@

- (void)loadForm:(id)args;

- (void)presentPrivacyOptionsForm:(id)args;

- (NSNumber *)isGDPR:(id)unused;

- (NSNumber *)canShowAds:(id)unused;

- (NSNumber *)canShowPersonalizedAds:(id)unused;

- (NSNumber *)isPrivacyOptionsRequired:(id)args;

- (NSNumber *)canRequestAds:(id)args;

- (void)requestConsentInfoUpdateForPublisherIdentifiers:(id)args; // REMOVED

- (void)showConsentForm:(id)args; // REMOVED
Expand Down
139 changes: 97 additions & 42 deletions ios/Classes/TiAdmobModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,49 +149,91 @@ - (void)requestConsentInfoUpdateWithParameters:(id)args
}];
}

- (void)loadForm:(id)args
-(void)loadForm:(id)args
{
ENSURE_SINGLE_ARG(args, NSDictionary);
ENSURE_SINGLE_ARG(args, NSDictionary);
KrollCallback *callback = [args objectForKey:@"callback"];

TiThreadPerformOnMainThread(
^{
UIViewController *viewController = [[[TiApp app] controller] topPresentedController];
// Automatically load and present the form if required
[UMPConsentForm loadAndPresentIfRequiredFromViewController:viewController
completionHandler:^(NSError *loadError) {
if (loadError) {
// Handle the error
[callback call:@[ @{ @"loadError" : loadError.localizedDescription } ] thisObject:self];
} else {
// Return the consent status
NSNumber *status = @(UMPConsentInformation.sharedInstance.consentStatus);
[callback call:@[ @{@"status" : status} ] thisObject:self];
}
}];

/*[UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form,
NSError *loadError) {
if (loadError) {
// Handle the error.
[callback call:@[ @{ @"loadError" : loadError.localizedDescription } ] thisObject:self];
} else {
// Present the form. You can also hold on to the reference to present
// later.
NSNumber *status = @(UMPConsentInformation.sharedInstance.consentStatus);
if (UMPConsentInformation.sharedInstance.consentStatus ==
UMPConsentStatusRequired) {
[form
presentFromViewController:[[[TiApp app] controller] topPresentedController]
completionHandler:^(NSError *_Nullable dismissError) {
if (UMPConsentInformation.sharedInstance.consentStatus ==
UMPConsentStatusObtained) {
// App can start requesting ads.
[callback call:@[ @{
@"status" : @(UMPConsentInformation.sharedInstance.consentStatus), // update here because it can change between the above assignment
@"dismissError" : NULL_IF_NIL(dismissError.localizedDescription)
} ]
thisObject:self];
return;
}
}];
} else {
[callback call:@[ @{
@"status" : status
} ]
thisObject:self];
}
}
}];*/
},
NO);
}

KrollCallback *callback = [args objectForKey:@"callback"];

TiThreadPerformOnMainThread(
^{
[UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form,
NSError *loadError) {
if (loadError) {
// Handle the error.
[callback call:@[ @{ @"loadError" : loadError.localizedDescription } ] thisObject:self];
} else {
// Present the form. You can also hold on to the reference to present
// later.
NSNumber *status = @(UMPConsentInformation.sharedInstance.consentStatus);
if (UMPConsentInformation.sharedInstance.consentStatus ==
UMPConsentStatusRequired) {
[form
presentFromViewController:[[[TiApp app] controller] topPresentedController]
completionHandler:^(NSError *_Nullable dismissError) {
if (UMPConsentInformation.sharedInstance.consentStatus ==
UMPConsentStatusObtained) {
// App can start requesting ads.
[callback call:@[ @{
@"status" : @(UMPConsentInformation.sharedInstance.consentStatus), // update here because it can change between the above assignment
@"dismissError" : NULL_IF_NIL(dismissError.localizedDescription)
} ]
thisObject:self];
return;
}
}];
-(void)presentPrivacyOptionsForm:(id)args
{
ENSURE_SINGLE_ARG(args, NSDictionary);
KrollCallback *callback = [args objectForKey:@"callback"];

TiThreadPerformOnMainThread(^{
UIViewController *viewController = [[[TiApp app] controller] topPresentedController];

[UMPConsentForm presentPrivacyOptionsFormFromViewController:viewController
completionHandler:^(NSError *error) {
if (error) {
// Handle the error
NSLog(@"[ERROR] presentPrivacyOptionsForm: %@", error.localizedDescription);
NSDictionary *result = @{ @"error": error.localizedDescription };
if (callback) {
[callback call:@[result] thisObject:self];
}

} else {
[callback call:@[ @{
@"status" : status
} ]
thisObject:self];
NSDictionary *result = @{ @"success": @(YES) };
if (callback) {
[callback call:@[result] thisObject:self];
}
}
}
}];
},
NO);
},
NO);
}

- (void)requestConsentInfoUpdateForPublisherIdentifiers:(id)args
Expand Down Expand Up @@ -296,6 +338,17 @@ - (BOOL)hasConsentOrLegitimateInterestFor:(NSArray *)purposes purposeConsent:(NS
return YES;
}

- (NSNumber*)isPrivacyOptionsRequired:(id)args
{
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
return NUMBOOL(status == UMPPrivacyOptionsRequirementStatusRequired);
}

- (NSNumber *)canRequestAds:(id)args
{
return NUMBOOL(UMPConsentInformation.sharedInstance.canRequestAds);
}

- (void)showConsentForm:(id)args
{
DEPRECATED_REMOVED(@"Admob.showConsentForm", @"5.0.0", @"5.0.0 (Removed since Ti.Admob 5.0.0 in favor of new UMP method Admob.requestConsentInfoUpdateWithParameters())");
Expand Down Expand Up @@ -490,11 +543,13 @@ - (void)setInMobi_updateGDPRConsent:(id)updateGDPRConsent
//MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_EEA, PACDebugGeographyEEA);
//MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_NOT_EEA, PACDebugGeographyNotEEA);

MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_DISABLED, UMPDebugGeographyDisabled);
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_EEA, UMPDebugGeographyEEA);
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_NOT_EEA, UMPDebugGeographyNotEEA);
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_DISABLED, UMPDebugGeographyDisabled); // 0
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_EEA, UMPDebugGeographyEEA); // 1
//MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_NOT_EEA, UMPDebugGeographyNotEEA); // 2 (Deprecated and deleted from 8.0.0)
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_REGULATED_US_STATE, UMPDebugGeographyRegulatedUSState); // 3
MAKE_SYSTEM_PROP(DEBUG_GEOGRAPHY_OTHER, UMPDebugGeographyOther); // 4

MAKE_SYSTEM_STR(SIMULATOR_ID, GADSimulatorID);
//MAKE_SYSTEM_STR(SIMULATOR_ID, GADSimulatorID); deleted from 8.0.0
//MAKE_SYSTEM_PROP(GENDER_MALE, kGADGenderMale); deleted from 4.5.0
//MAKE_SYSTEM_PROP(GENDER_FEMALE, kGADGenderFemale); deleted from 4.5.0
//MAKE_SYSTEM_PROP(GENDER_UNKNOWN, kGADGenderUnknown); deleted from 4.5.0
Expand Down
Loading