Git Product home page Git Product logo

ti.playservices's Introduction

ti.playservices

To provide Google Play Services for Titanium modules and applications

Requirements

  • Titanium Mobile SDK 7.0.0 or later (release 12/2017)

Example

Add the module as a dependency to your application by adding a <module> item to the <modules> element of your tiapp.xml file:

<ti:app>
  ...
  <modules>
    <module platform="android">ti.playservices</module>
  </modules>
  ...
</ti:app>

Use require() to access the module from JavaScript:

    const PlayServices = require('ti.playservices');

The PlayServices variable is a reference to the module. Make API calls using this reference:

    const playServicesAvailable = PlayServices.isGooglePlayServicesAvailable();

As of version 17.1.0 (only supported by Titanium Mobile SDK 9.0.0 and above), the ti.playservices module will automatically check if Google Play Services is installed and up-to-date on the device upon app startup. If not, the module will prompt the end-user to install/update it. The main app script (ie: app.js or alloy.js) will not be executed until the end-user has successfully installed/updated Google Play Services or if it is already up-to-date.

If you do not want ti.playservices to check Google Play Services on app startup, then you can disable the above mentioned behavior by setting the below property in the tiapp.xml file.

<ti:app xmlns:ti="http://ti.appcelerator.org">
	<property name="ti.playservices.validate.on.startup" type="bool">false</property>
</ti:app>

If you disable the above behavior, then it is highly recommended to detect availability issues yourself as shown below.

const PlayServices = require('ti.playservices');

const win = Ti.UI.createWindow({ backgroundColor: 'gray' });
const btn = Ti.UI.createButton({ title: 'CHECK PLAY SERVICES' });

btn.addEventListener('click', () => {
    PlayServices.makeGooglePlayServicesAvailable((e) => {
        if (e.success) {
            alert(`Play Services: ${PlayServices.GOOGLE_PLAY_SERVICES_VERSION_CODE}`);
            // Use Play Services
        } else {
            alert(`Play Services is not available.`);
        }
    });
});

win.add(btn);
win.open();

To include Play Services libraries with your native module include the module as a dependency by adding a <module> item to the <modules> element of your timodule.xml file:

<ti:module>
  ...
  <modules>
    <module platform="android">ti.playservices</module>
  </modules>
  ...
</ti:module>

For a detailed API example please see android/example/app.js

Build

  1. Create a lib folder in the android directory
  2. Run npm install node . from the updater directory
  3. Run npm install && node . from the updater directory
  4. Run appc run -p android --build-only from the android directory

Author

Axway

License

Apache 2.0

Contributing

Code contributions are greatly appreciated, please submit a new pull request!

ti.playservices's People

Contributors

caspahouzer avatar cb1kenobi avatar dependabot-preview[bot] avatar dependabot[bot] avatar ewanharris avatar garymathews avatar hansemannn avatar janvennemann avatar jawa9000 avatar jquick-axway avatar m1ga avatar sgtcoolguy avatar ssjsamir avatar ypbnv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ti.playservices's Issues

Didn't find class com.google.android.gms.common.internal.zzbo

Hello my ti.playservices version was 11.0.40 I upgraded it to 16.1.2. After that I am getting error as below I have tried 16.1.0 too result is same. My jira ticket is https://jira.appcelerator.org/browse/AC-6141

02-27 13:00:30.485 12645 12645 E AndroidRuntime: FATAL EXCEPTION: main
02-27 13:00:30.485 12645 12645 E AndroidRuntime: Process: com.sizebiz.just.live.basketball, PID: 12645
02-27 13:00:30.485 12645 12645 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbo;
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread.installProvider(ActivityThread.java:6414)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:5961)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5867)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread.access$1100(ActivityThread.java:200)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1651)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6692)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbo" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.sizebiz.just.live.basketball-Rn8Kb-p0JpC_xcova1olLg==/base.apk"],nativeLibraryDirectories=[/data/app/com.sizebiz.just.live.basketball-Rn8Kb-p0JpC_xcova1olLg==/lib/arm64, /data/app/com.sizebiz.just.live.basketball-Rn8Kb-p0JpC_xcova1olLg==/base.apk!/lib/arm64-v8a, /system/lib64]]
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
02-27 13:00:30.485 12645 12645 E AndroidRuntime: 	... 12 more
02-27 13:00:30.487  2047  9545 W ActivityManager:   Force finishing activity com.sizebiz.just.live.basketball/.JustLiveBasketballActivity

error compiling

when compiling my project whit this module i gent the following error:

[ERROR] Application Installer abnormal process termination. Process exit value was 1
[ERROR] : Failed to run dexer:
[ERROR] :
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/ItemListIntents;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/NoteIntents;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/ReserveIntents;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/SearchIntents;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/AccountChangeEvent;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/AccountChangeEventsRequest;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/AccountChangeEventsResponse;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/GoogleAuthException;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/GoogleAuthUtil;
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.RuntimeException: Translation has been interrupted
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:615)
[ERROR] : at com.android.dx.command.dexer.Main.runMultiDex(Main.java:368)
[ERROR] : at com.android.dx.command.dexer.Main.runDx(Main.java:289)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:247)
[ERROR] : at com.android.dx.command.Main.main(Main.java:94)
[ERROR] : Caused by: java.lang.InterruptedException: Too many errors
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:607)
[ERROR] : ... 4 more

Access Play Services Functions

Since it looks like all of the play services libraries are included, what is the method to instantiate an instance of a service? For example, play-services-location-11.0.4.aar is included, but how would you create then reference the API calls from that aar?

More granular Google Play Services dependencies

Hey guys.

First I would like to thank you for making this module, was quite anticipated by some of us, since now it frees us from having Google Play Services JAR as direct dependency in modules we write. Never the less, wanted to check this with you. When using your module, I see that following things are being added to the app in dexer phase:

build/android/intermediates/exploded-aar/play-services-ads-lite-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-analytics-impl-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-appinvite-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-auth-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-auth-base-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-awareness-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-base-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-basement-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-cast-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-cast-framework-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-gcm-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-identity-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-iid-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-location-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-maps-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-nearby-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-tasks-11.0.4/classes.jar" 
build/android/intermediates/exploded-aar/play-services-wallet-11.0.4/classes.jar"

I might be only interested in adding -basement module to my plugin and the rest is of no interest to me. By advising client to add your current module, method count will get quite increased and might breach 65K limit for some. With that in mind:

I was wondering if there are any plans to build support for adding separate modules as dependencies?

So something which can be added to user's tiapp.xml like this:

<module platform="android">ti.playservices.basement</module>

?

Thanks in advance for your reply.

Cheers

Module Not Found Error.

Hi,

I'm trying using this module but always return "module not found error", I follow the code example but the error still (put in Tiapp and require), I'm use Win 10, SDK Ti 6.2.2.GA (The SDK Ti 6.3.1.GA describe in requirement doc I can't find). I'm donwloaded from here SDK 6.3.0.GA and 7.0.0 but the same problem it occurred.

Can this module transfer map data to the app?

Can this module transfer card data from my app to the app 'Google play'? For example, the card number, card holder and cvv for subsequent card registration in the Google play. How it can be done?

16.1.5: Androidx error -> crash

I was testing 16.1.5 today with my FCM test app. It will crash with:

[ERROR] FirebaseApp: Firebase API initialization failure.
[ERROR] FirebaseApp: java.lang.reflect.InvocationTargetException
[ERROR] FirebaseApp:    at java.lang.reflect.Method.invoke(Native Method)
[ERROR] FirebaseApp:    at com.google.firebase.FirebaseApp.initializeApis(com.google.firebase:firebase-common@@16.1.0:815)
[ERROR] FirebaseApp:    at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@16.1.0:785)
[ERROR] FirebaseApp:    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.1.0:369)
[ERROR] FirebaseApp:    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.1.0:332)
[ERROR] FirebaseApp:    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.1.0:316)
[ERROR] FirebaseApp:    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@16.1.0:53)
[ERROR] FirebaseApp:    at android.content.ContentProvider.attachInfo(ContentProvider.java:1793)
[ERROR] FirebaseApp:    at android.content.ContentProvider.attachInfo(ContentProvider.java:1762)
[ERROR] FirebaseApp:    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@16.1.0:47)
[ERROR] FirebaseApp:    at android.app.ActivityThread.installProvider(ActivityThread.java:6141)
[ERROR] FirebaseApp:    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5704)
[ERROR] FirebaseApp:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5643)
[ERROR] FirebaseApp:    at android.app.ActivityThread.-wrap2(ActivityThread.java)
[ERROR] FirebaseApp:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573)
[ERROR] FirebaseApp:    at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] FirebaseApp:    at android.os.Looper.loop(Looper.java:173)
[ERROR] FirebaseApp:    at android.app.ActivityThread.main(ActivityThread.java:6459)
[ERROR] FirebaseApp:    at java.lang.reflect.Method.invoke(Native Method)
[ERROR] FirebaseApp:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
[ERROR] FirebaseApp:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
[ERROR] FirebaseApp: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/ArrayMap;
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzcm.<clinit>(com.google.android.gms:play-services-measurement-impl@@17.2.0:7)
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzcm.zza(com.google.android.gms:play-services-measurement-impl@@17.2.0:1)
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzla.<clinit>(com.google.android.gms:play-services-measurement-impl@@17.2.0:5)
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzky.<init>(com.google.android.gms:play-services-measurement-impl@@17.2.0:6)
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzky.<clinit>(com.google.android.gms:play-services-measurement-impl@@17.2.0:11)
[ERROR] FirebaseApp:    at com.google.android.gms.internal.measurement.zzky.zzb(com.google.android.gms:play-services-measurement-impl@@17.2.0:1)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.internal.zzap.<clinit>(com.google.android.gms:play-services-measurement-impl@@17.2.0:542)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.internal.zzap.zza(com.google.android.gms:play-services-measurement-impl@@17.2.0:21)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.internal.zzfx.<init>(com.google.android.gms:play-services-measurement-impl@@17.2.0:8)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.internal.zzfx.zza(com.google.android.gms:play-services-measurement-impl@@17.2.0:305)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.internal.zzfx.zza(com.google.android.gms:play-services-measurement-impl@@17.2.0:294)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.AppMeasurement.zza(com.google.android.gms:play-services-measurement-impl@@17.2.0:9)
[ERROR] FirebaseApp:    at com.google.android.gms.measurement.AppMeasurement.getInstance(com.google.android.gms:play-services-measurement-impl@@17.2.0:1)
[ERROR] FirebaseApp:    ... 21 more
[ERROR] FirebaseApp: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.collection.ArrayMap" on path: DexPathList[[zip file "/data/app/com.miga.testfirebase-1/base.apk"],nativeLibraryDirectories=[/data/app/com.miga.testfirebase-1/lib/arm64, /data/app/com.miga.testfirebase-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]                                                                                    
[ERROR] FirebaseApp:    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[ERROR] FirebaseApp:    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
[ERROR] FirebaseApp:    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[ERROR] FirebaseApp:    ... 34 more

I'm not sure if I need to recompile FCM modules with newer playservice libs or if there is any androidx component inside the libs of ti.playservice 16.1.5 that are not supported (the error points to ArrayMap). So currently the best version to use is 16.1.4 and remove the ads-lite lib.

Google Play Services Version?

Is it possible to include in the manifest or other file the version of the Google PlayServices jar?

This would help us module developers in figuring out what version we should link against.

Using within an existing Ti Native Module

Thanks for putting this together. Is there any examples on how to use this as a dependency within a native module. I see that the Ti.Map uses this as a dependency but I can't figure out how to add the module or it's lib dependencies to my path.

Would be great to have all of the module developers use a common source for Google Play Services. But, need alittle help on how to reference the module from within Eclipse.

16.1.4 Crashes my app

16.1.3 was running just fine but once I installed 16.1.4 the app crashes immediately on startup

App crashed in runtime with Ti SDK 10.0.0

When I added module Ti.Playservices in Tiapp.xml, the app compiled and opened but crashed at runtime with below error without hitting alloy.js . I have tried on version 17.1.1, 17.3.0 and 17.5.0. In version 16.1.3 compiling failed with error in Ti SDK 10

Tiapp.xml

<modules> <module platform="android">ti.playservices</module> </modules>

Error

[ERROR] TiExceptionHandler: (main) [91,91] ti:/kroll.js:1045 [ERROR] TiExceptionHandler: throw new Error(Requested module not found: ${request}); // TODO Set 'code' property to 'MODULE_NOT_FOUND' to match Node? [ERROR] TiExceptionHandler: ^ [ERROR] TiExceptionHandler: Error: Requested module not found: ti.playservices\ti.playservices.bootstrap [ERROR] TiExceptionHandler: at Module.require (ti:/kroll.js:1045:14) [ERROR] TiExceptionHandler: at Module.global.Module.require (<embedded>:5086:32) [ERROR] TiExceptionHandler: at require (ti:/kroll.js:1315:22) [ERROR] TiExceptionHandler: at global.require (<embedded>:5071:10) [ERROR] TiExceptionHandler: at doLoad (<embedded>:11198:27) [ERROR] TiExceptionHandler: at loadBootstrapScripts (<embedded>:11224:5) [ERROR] TiExceptionHandler: at loadAsync (<embedded>:11229:3) [ERROR] TiExceptionHandler: at _startSnapshot (<embedded>:11246:1) [ERROR] TiExceptionHandler: at /ti.main.js:1:8 [ERROR] TiExceptionHandler: at Module._runScript (ti:/kroll.js:1342:24) [ERROR] TiExceptionHandler: [ERROR] TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [ERROR] TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:175) [ERROR] TiExceptionHandler: org.appcelerator.titanium.TiApplication.launch(TiApplication.java:868) [ERROR] TiExceptionHandler: org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:96) [ERROR] TiExceptionHandler: org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:497) [ERROR] TiExceptionHandler: org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:177) [ERROR] TiExceptionHandler: org.appcelerator.titanium.TiRootActivity.onResume(TiRootActivity.java:516) [ERROR] TiExceptionHandler: android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1453) [ERROR] TiExceptionHandler: android.app.Activity.performResume(Activity.java:7962) [ERROR] TiExceptionHandler: android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195) [ERROR] V8Exception: Exception occurred at ti:/kroll.js:1045: Uncaught Error: Requested module not found: ti.playservices\ti.playservices.bootstrap

Using 11.8.0 app crashes

Using 11.8.0 app won't launch and crashes with no error

-- Start application log -----------------------------------------------------
[INFO] : MultiDex: VM with version 2.1.0 has multidex support
[INFO] : MultiDex: Installing application
[INFO] : MultiDex: VM has multidex support, MultiDex support library is disabled.

App then simply crashes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.