Skip to content

Commit

Permalink
Merge pull request #10 from muhammaddadu/TIMODOPEN-461
Browse files Browse the repository at this point in the history
[TIMODOPEN-461] AdMob: Add isGooglePlayServicesAvailable method to module
  • Loading branch information
jonalter committed Nov 14, 2014
2 parents f0baacc + c73b5b6 commit c38303c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions android/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log
<pre>
v2.1.4 Added isGooglePlayServicesAvailable method [TIMODOPEN-461]

v2.1.3 Updating to use google-play-services library [TIMODOPEN-454]

v2.1.2 Updating to use google-play-services library [TIMODOPEN-445]
Expand Down
24 changes: 24 additions & 0 deletions android/documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ The "Admob" variable is now a reference to the Module object.

## Functions

### number isGooglePlayServicesAvailable()

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`.

### createAdMobView({ . . . })

Returns a view with an ad initialized by default.
Expand Down Expand Up @@ -97,6 +103,24 @@ Calls for a test ad if needed. This works independently from the testing flag ab

adMobView.requestTestAd();

## Constants

### number SUCCESS
Returned by `isGooglePlayServicesAvailable` if the connection to Google Play services was successful.

### number SERVICE_MISSING
Returned by `isGooglePlayServicesAvailable` if Google Play services is missing on this device.

### number SERVICE_VERSION_UPDATE_REQUIRED
Returned by `isGooglePlayServicesAvailable` if the installed version of Google Play services is out of date.

### number SERVICE_DISABLED
Returned by `isGooglePlayServicesAvailable` if the installed version of Google Play services has been disabled on this device.

### number SERVICE_INVALID
Returned by `isGooglePlayServicesAvailable` if the version of the Google Play services installed on this device is not authentic.


## Module History

View the [change log](changelog.html) for this module.
Expand Down
6 changes: 6 additions & 0 deletions android/example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ var win = Titanium.UI.createWindow({
// require AdMob
var Admob = require('ti.admob');

// check if google play services are available
var code = Admob.isGooglePlayServicesAvailable();
if (code != Admob.SUCCESS) {
alert("Google Play Services is not installed/updated/available");
}

// then create an adMob view
var adMobView = Admob.createView({
publisherId:"<<YOUR PUBLISHER ID HERE>>",
Expand Down
2 changes: 1 addition & 1 deletion android/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.1.3
version: 2.1.4
apiversion: 2
description: Titanium Admob module for Android
author: Brian Kurzius
Expand Down
14 changes: 14 additions & 0 deletions android/src/ti/admob/AdmobModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import com.google.android.gms.common.GooglePlayServicesUtil;

@Kroll.module(name = "Admob", id = "ti.admob")
public class AdmobModule extends KrollModule {
Expand Down Expand Up @@ -41,6 +43,18 @@ public AdmobModule() {
Log.d(TAG, "adMob module instantiated");
}

// Response from isGooglePlayServicesAvailable()
@Kroll.constant public static final int SUCCESS = 0;
@Kroll.constant public static final int SERVICE_MISSING = 1;
@Kroll.constant public static final int SERVICE_VERSION_UPDATE_REQUIRED = 2;
@Kroll.constant public static final int SERVICE_DISABLED = 3;
@Kroll.constant public static final int SERVICE_INVALID = 9;

@Kroll.method
public int isGooglePlayServicesAvailable() {
return GooglePlayServicesUtil.isGooglePlayServicesAvailable(TiApplication.getAppRootOrCurrentActivity());
}

// use this to set the publisher id
// must be done before the call to instantiate the view
@Kroll.method
Expand Down

0 comments on commit c38303c

Please sign in to comment.