diff --git a/android/documentation/changelog.md b/android/documentation/changelog.md index 9043e6c0..ccbfc481 100644 --- a/android/documentation/changelog.md +++ b/android/documentation/changelog.md @@ -1,5 +1,7 @@ # Change Log
+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] diff --git a/android/documentation/index.md b/android/documentation/index.md index 07256ea8..b987c57e 100644 --- a/android/documentation/index.md +++ b/android/documentation/index.md @@ -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. @@ -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. diff --git a/android/example/app.js b/android/example/app.js index 66836a7b..3179c7da 100644 --- a/android/example/app.js +++ b/android/example/app.js @@ -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:"<>", diff --git a/android/manifest b/android/manifest index 4e30e860..46566b85 100644 --- a/android/manifest +++ b/android/manifest @@ -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 diff --git a/android/src/ti/admob/AdmobModule.java b/android/src/ti/admob/AdmobModule.java index e2177a65..f55295e2 100644 --- a/android/src/ti/admob/AdmobModule.java +++ b/android/src/ti/admob/AdmobModule.java @@ -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 { @@ -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