Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-24473
Browse files Browse the repository at this point in the history
  • Loading branch information
ypbnv authored Nov 1, 2018
2 parents ed1099d + ba7b5c1 commit 30ae091
Show file tree
Hide file tree
Showing 46 changed files with 2,755 additions and 24 deletions.
6 changes: 2 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@Library('pipeline-library') _

buildModule {
// defaults:
//nodeVersion = '4.7.3' // Must have version set up on Jenkins master before it can be changed
sdkVersion = '7.1.0.v20180127081155' // use a master build with ARM64 support
//androidAPILevel = '23' // if changed, must install on build nodes
nodeVersion = '8.9.1'
sdkVersion = '7.2.0.GA'
}
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ repositories {

dependencies {
implementation 'com.google.android.ads.consent:consent-library:1.0.1'
implementation 'com.facebook.android:audience-network-sdk:4.28.2'
implementation 'com.google.ads.mediation:facebook:4.28.2.0'
}

task getDeps(type: Copy) {
Expand Down
11 changes: 9 additions & 2 deletions android/documentation/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

<pre>

v4.2.0 Maintain API parity with iOS module
v4.4.0 Maintain API parity with iOS module and introduce Interstitial ads support on Android.

v4.3.0 Support the Facebook Audience Network adapter
Android integration guide: https://developers.google.com/admob/android/mediation/facebook

v4.2.1 Fix Kroll annotation for requestConsentInfoUpdateForPublisherIdentifiers.

v4.2.0 Expose getId() and isAdTrackingLimited() from AdvertisingIdClient.Info.

v4.1.0 Conform to GDPR by exposing the `extras` object to `requestAd()` [MOD-2423]

v4.0.0 Support Titanium SDK 7.0.0 and Android 64-Bit, use Ti.PlayServices

v3.0.2 Bump Google Play Services to 10.2.0 [TIMOB-24722]
v3.0.2 Bump Google Play Services to 10.2.0 [TIMOB-24722]

v3.0.1 Update Google Play Services to v9.6.1 (revison 33) [TIMOB-23860]

Expand Down
47 changes: 40 additions & 7 deletions android/documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

## Description

Allows for the display of AdMob in Titanium Android applications.
Allows for the display of AdMob in Titanium Android applications.

Please note that if your androidManifest has screen support set to: android:anyDensity="false", any banner ads will display too small on high density devices.
It is not clear at this point if this is a bug with AdMob or Titanium.
Please note that if your androidManifest has screen support set to: android:anyDensity="false", any banner ads will
display too small on high density devices.
It is not clear at this point if this is a bug with AdMob or Titanium.
In any event, you will either need to NOT set your screen support -- or set android:anyDensity="true" and adjust your app layout accordingly

## Getting Started

View the [Using Titanium Modules](http://docs.appcelerator.com/titanium/latest/#!/guide/Using_Titanium_Modules) document for instructions on getting
started with using this module in your application.
View the [Using Titanium Modules](http://docs.appcelerator.com/titanium/latest/#!/guide/Using_Titanium_Modules) document
for instructions on getting started with using this module in your application.

## Requirements

Expand All @@ -26,7 +27,7 @@ To access this module from JavaScript, you would do the following (recommended):
var Admob = require('ti.admob');
```

The "Admob" variable is now a reference to the Module object.
The "Admob" variable is now a reference to the Module object.

## Doubleclick for Publishers Developer Docs

Expand All @@ -38,7 +39,8 @@ The "Admob" variable is now a reference to the Module object.

Returns a number value indicating the availability of Google Play Services which are for push notifications.

Possible values include `SUCCESS`, `SERVICE_MISSING`, `SERVICE_VERSION_UPDATE_REQUIRED`, `SERVICE_DISABLED`, and `SERVICE_INVALID`.
Possible values include `SUCCESS`, `SERVICE_MISSING`, `SERVICE_VERSION_UPDATE_REQUIRED`, `SERVICE_DISABLED`,
and `SERVICE_INVALID`.

### `createAdMobView(args)`

Expand Down Expand Up @@ -155,6 +157,37 @@ Array of ad providers.

Debug geography. Used for debug devices only.

### getAndroidAdId(callback)

Gets the user Android Advertising ID. Since this works in a background thread in native
Android a callback is called when the value is fetched. The callback parameter is a key/value
pair with key `androidAdId` and a String value with the id.

#### Example:

Admob.getAndroidAdId(function (data) {
Ti.API.info('AAID is ' + data.aaID);
});

### isLimitAdTrackingEnabled(callback)

Checks whether the user has opted out from ad tracking in the device's settings. Since
this works in a background thread in native Android a callback is called when the value
is fetched. The callback parameter is a key/value pair with key `isLimitAdTrackingEnabled`
and a boolean value for the user's setting.

#### Example:

Admob.isLimitAdTrackingEnabled(function (data) {
Ti.API.info('Ad tracking is limited: ' + data.isLimitAdTrackingEnabled);
});

### Support the Facebook Audience Network adapter

Starting in 4.3.0 you can use the included Facebook Audience Network adapter to turn on the mediation in your AdMob account.
Here you do not have to do anything 😙. You only need to configure mediation in your AdMob and Facebook accounts by
following the [official guide](https://developers.google.com/admob/android/mediation/facebook).

## Constants

### Number `SUCCESS`
Expand Down
28 changes: 28 additions & 0 deletions android/example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,35 @@ adRequestBtn2.addEventListener("click",function(){
adMobView.requestTestAd();
});

var getAAID = Ti.UI.createButton({
title: "Get AAID",
top: "40%",
height: "10%",
width: "80%"
});

var getIsAdTrackingLimited = Ti.UI.createButton({
title: "Is Ad tracking limited",
top: "55%",
height: "10%",
width: "80%"
});

getAAID.addEventListener('click', function() {
Admob.getAndroidAdId(function (data) {
Ti.API.info('AAID is ' + data.aaID);
});
});

getIsAdTrackingLimited.addEventListener('click', function() {
Admob.isLimitAdTrackingEnabled(function (data) {
Ti.API.info('Ad tracking is limited: ' + data.isLimitAdTrackingEnabled);
});
})

win.add(adMobView);
win.add(adRequestBtn);
win.add(adRequestBtn2);
win.add(getAAID);
win.add(getIsAdTrackingLimited)
win.open();
Binary file added android/lib/audience-network-sdk-4.28.2.aar
Binary file not shown.
Binary file added android/lib/facebook-4.28.2.0.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# during compilation, packaging, distribution, etc.
#

version: 4.2.0
version: 4.4.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: Titanium Admob module for Android
Expand Down
76 changes: 75 additions & 1 deletion android/src/ti/admob/AdmobModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@

package ti.admob;

import android.os.AsyncTask;

import java.io.IOException;

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;

import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollObject;
Expand Down Expand Up @@ -44,9 +56,13 @@ public class AdmobModule extends KrollModule
private static final String TAG = "AdmobModule";
public static String MODULE_NAME = "AndroidAdMobModule";

private final String ANDROID_ADVERTISING_ID = "androidAdId";
private final String IS_LIMIT_AD_TRACKING_ENABLED = "isLimitAdTrackingEnabled";

public static Boolean TESTING = false;

private ConsentForm form = null;

public static boolean TESTING = false;
public static String PUBLISHER_ID;

// constants
Expand Down Expand Up @@ -137,6 +153,63 @@ public void setTesting(boolean testing)
TESTING = testing;
}

@Kroll.method
public void isLimitAdTrackingEnabled(KrollFunction callback) {
if (callback != null) {
new getAndroidAdvertisingIDInfo(callback).execute(IS_LIMIT_AD_TRACKING_ENABLED);
}
}

@Kroll.method
public void getAndroidAdId(KrollFunction callback) {
if (callback != null) {
new getAndroidAdvertisingIDInfo(callback).execute(ANDROID_ADVERTISING_ID);
}
}

private void invokeAIDClientInfoCallback(AdvertisingIdClient.Info aaClientIDInfo, String responseKey, KrollFunction callback) {
KrollDict callbackDictionary = new KrollDict();
Object responseValue = null;
switch (responseKey) {
case ANDROID_ADVERTISING_ID:
responseValue = aaClientIDInfo.getId();
break;
case IS_LIMIT_AD_TRACKING_ENABLED:
responseValue = aaClientIDInfo.isLimitAdTrackingEnabled();
break;
}
callbackDictionary.put(responseKey, responseValue);
callback.callAsync(getKrollObject(), callbackDictionary);
}

private class getAndroidAdvertisingIDInfo extends AsyncTask<String, Integer, String> {

private AdvertisingIdClient.Info aaClientIDInfo = null;
private KrollFunction aaInfoCallback;

public getAndroidAdvertisingIDInfo(KrollFunction infoCallback) {
this.aaInfoCallback = infoCallback;
}

@Override
protected String doInBackground(String... responseKey) {
try {
aaClientIDInfo = AdvertisingIdClient.getAdvertisingIdInfo(TiApplication.getInstance().getApplicationContext());
return responseKey[0];
} catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
e.printStackTrace();
return null;
}
}

@Override
protected void onPostExecute(String responseKey) {
if (aaClientIDInfo != null) {
invokeAIDClientInfoCallback(aaClientIDInfo, responseKey, aaInfoCallback);
}
}
}

@Kroll.method
public void requestConsentInfoUpdateForPublisherIdentifiers(KrollDict args)
{
Expand Down Expand Up @@ -360,4 +433,5 @@ public KrollDict[] getAdProviders()

return result;
}

}
8 changes: 8 additions & 0 deletions ios/admob.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
24DD6CFA1134B3F500162E58 /* TiAdmobModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* TiAdmobModule.m */; };
3A4F268F1C68DDF7003E06CF /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A4F268E1C68DDF7003E06CF /* iAd.framework */; };
3AF5B7731C233383002E3DC7 /* TiAdmobTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AF5B7711C233383002E3DC7 /* TiAdmobTypes.h */; };
5E32C3FB20E2957400A17A2B /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E32C3F920E2957400A17A2B /* FBAudienceNetwork.framework */; };
5E32C3FC20E2957400A17A2B /* FacebookAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E32C3FA20E2957400A17A2B /* FacebookAdapter.framework */; };
AA747D9F0F9514B9006C5449 /* TiAdmob_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* TiAdmob_Prefix.pch */; };
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
CE6C17A01982D1170017C788 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE6C179F1982D1170017C788 /* AdSupport.framework */; };
Expand Down Expand Up @@ -48,6 +50,8 @@
24DD6D1B1134B66800162E58 /* titanium.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = titanium.xcconfig; sourceTree = "<group>"; };
3A4F268E1C68DDF7003E06CF /* iAd.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iAd.framework; path = System/Library/Frameworks/iAd.framework; sourceTree = SDKROOT; };
3AF5B7711C233383002E3DC7 /* TiAdmobTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiAdmobTypes.h; path = Classes/TiAdmobTypes.h; sourceTree = "<group>"; };
5E32C3F920E2957400A17A2B /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBAudienceNetwork.framework; path = platform/FBAudienceNetwork.framework; sourceTree = "<group>"; };
5E32C3FA20E2957400A17A2B /* FacebookAdapter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookAdapter.framework; path = platform/FacebookAdapter.framework; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* TiAdmob_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiAdmob_Prefix.pch; sourceTree = SOURCE_ROOT; };
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
CE6C179F1982D1170017C788 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -84,12 +88,14 @@
DAD5D7CF12527E11009CF986 /* AudioToolbox.framework in Frameworks */,
CE6C17A21982D12D0017C788 /* AVFoundation.framework in Frameworks */,
CE6C17A41982D13A0017C788 /* CoreGraphics.framework in Frameworks */,
5E32C3FB20E2957400A17A2B /* FBAudienceNetwork.framework in Frameworks */,
DB07E8B81E8010000008C1E1 /* CoreMedia.framework in Frameworks */,
DB07E8B91E8010000008C1E1 /* CoreMotion.framework in Frameworks */,
CE6C17A61982D1660017C788 /* CoreTelephony.framework in Frameworks */,
DB07E8BB1E80100D0008C1E1 /* CoreVideo.framework in Frameworks */,
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */,
DB07E8BD1E80101A0008C1E1 /* GLKit.framework in Frameworks */,
5E32C3FC20E2957400A17A2B /* FacebookAdapter.framework in Frameworks */,
DB07E8BF1E80101F0008C1E1 /* JavaScriptCore.framework in Frameworks */,
DB07E8C01E80103C0008C1E1 /* MediaPlayer.framework in Frameworks */,
DAD5D7D512527E2F009CF986 /* MessageUI.framework in Frameworks */,
Expand Down Expand Up @@ -126,6 +132,8 @@
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
5E32C3FA20E2957400A17A2B /* FacebookAdapter.framework */,
5E32C3F920E2957400A17A2B /* FBAudienceNetwork.framework */,
DB28410320B413750099933A /* PersonalizedAdConsent.framework */,
DB2840FA20B408760099933A /* GoogleMobileAds.framework */,
DB07E8C51E8010680008C1E1 /* SafariServices.framework */,
Expand Down
7 changes: 5 additions & 2 deletions ios/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log
<pre>
v2.4.0 Support the Facebook Audience Network adapter
iOS integration guide: https://developers.google.com/admob/ios/mediation/facebook

v2.3.0 [MOD-2196] Update AdMob to 7.31.0, conform to GDPR

v2.2.0 Update Admob iOS SDK to 7.27.0, remove iAd adapter due to Google removal
Expand All @@ -8,7 +11,7 @@ v2.1.0 [MOD-2196] Support the iAd adapter

v2.0.0 [MOD-2182] Updating Admob SDK to 7.6.0, support iOS 9, support for new API's'

v1.9.0 [TIMOB-18092] ti.admob added 64bit support for iOS #15
v1.9.0 [TIMOB-18092] ti.admob added 64bit support for iOS #15

v1.8.0 [TIMOB-17928] Updated to build for 64-bit

Expand All @@ -22,7 +25,7 @@ v1.6.0 [TIMODOPEN-427] Updating Admob SDK to 6.10.0, Building with TiSDK 3.2.3.
v1.5.0 [TIMODOPEN-242] Updating Admob SDK to 6.4.2 (Removed all uses of UDID)

v1.4.0 [TIMODOPEN-212] Updating Admob SDK to 6.2.1, Building with TiSDK 2.1.3.GA, update documentation

v1.3 Fixed crash on iOS 4.3 [MOD-600]

v1.2 Upgraded to SDK 5.0.5 [MOD-410]
Expand Down
11 changes: 7 additions & 4 deletions ios/documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ parameters[object]: a dictionary object of properties defined in [Ti.Admob.View]

```js
var ad = Admob.createView({
bottom: 0,
bottom: 0,
width: 320, // Will calculate the width internally to fit its container if not specified
height: 50,
debugEnabled: true, // If enabled, a dummy value for `adUnitId` will be used to test
adType: Admob.AD_TYPE_BANNER, // One of `AD_TYPE_BANNER` (default) or `AD_TYPE_INTERSTITIAL`
adUnitId: '<<YOUR ADD UNIT ID HERE>>', // You can get your own at http: //www.admob.com/
adBackgroundColor: 'black',
adBackgroundColor: 'black',
testDevices: [Admob.SIMULATOR_ID], // You can get your device's id by looking in the console log
contentURL: 'https://admob.com', // URL string for a webpage whose content matches the app content.
requestAgent: 'Titanium Mobile App', // String that identifies the ad request's origin.
Expand Down Expand Up @@ -122,8 +122,8 @@ Debug geography. Used for debug devices only.

### Interstitials

To receive an interstitional ad, you need to call `ad.receive()` instead of adding it to the viewe hierarchy.
It fires the `didReceiveAd` event if the ad was successfully received, the `didFailToReceiveAd` event otherwise. Please check
To receive an interstitional ad, you need to call `ad.receive()` instead of adding it to the viewe hierarchy.
It fires the `didReceiveAd` event if the ad was successfully received, the `didFailToReceiveAd` event otherwise. Please check
the example for a detailed example of different banner types.

### iAd
Expand All @@ -132,6 +132,9 @@ the example for a detailed example of different banner types.

Starting in 2.1.0 you can use the included iAd adapter to turn on the iAd mediation in your Admob account.

### Support the Facebook Audience Network adapter

Starting in 2.4.0 you can use the included Facebook Audience Network adapter to turn on the mediation in your Admob account. Here you do not have to do anything :) You only need to configure mediation in your AdMob and Facebbok accounts by following the official guide: https://developers.google.com/admob/ios/mediation/facebook

## Constants

Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.3.0
version: 2.4.0
architectures: armv7 i386 x86_64 arm64
description: AdMob module for ad delivery via AdMob
author: Jeff Haynie, Stephen Tramer, Jasper Kennis, Jon Alter and Hans Knoechel
Expand Down
2 changes: 1 addition & 1 deletion ios/module.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OTHER_LDFLAGS=$(inherited) -framework AdSupport -framework AudioToolbox -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreMotion -framework CoreTelephony -framework CoreVideo -framework Foundation -framework GLKit -framework JavaScriptCore -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework OpenGLES -framework SafariServices -framework iAd -framework StoreKit -framework SystemConfiguration -framework WebKit -framework GoogleMobileAds -framework PersonalizedAdConsent
OTHER_LDFLAGS=$(inherited) -framework AdSupport -framework AudioToolbox -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreMotion -framework CoreTelephony -framework CoreVideo -framework Foundation -framework GLKit -framework JavaScriptCore -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework OpenGLES -framework SafariServices -framework iAd -framework StoreKit -framework SystemConfiguration -framework WebKit -framework GoogleMobileAds -framework PersonalizedAdConsent -framework FacebookAdapter -framework FBAudienceNetwork
Binary file not shown.
Loading

0 comments on commit 30ae091

Please sign in to comment.