Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Last Updated:

Lastupdatedate

Livesearch
placeholderSearch the Vibes Developer Wiki
typepage




This is an Android SDK for handling push integration with the Vibes Platform APIs.

The compiled Android repository SDK is available on the Vibes GitHub Repository.

Note
Note: You can reference the Android SDK code here.

Table of Contents

Installing the Android SDK

  1. Click Add Firebase and follow the instructions on the Firebase website. This will include setting up the Google Services plugin and downloading the google-services.json into your App folder.

  2. Click Add Firebase Cloud Messaging and follow the instructions. This will include adding two services to your app to handle app token refresh and incoming push notifications.

  3. Add the Vibes SDK by doing the following:

    1. Add the following to your project-level build.gradle file:

      Code Block
      maven {
         url     url "https://githubraw.githubusercontent.com/vibes/android-sdk-repository/releases/"
      }


    2. Add the following to your app-level build.gradle file:

      Code Block
      dependencies {
            // other dependencies here
         compile   
      	implementation "com.vibes.vibes:vibes:14.4.+3"
      }

       

  4. Sync your project in Android Studio.

Using an Older Version of Google Services

If you are using an older version of Google Services (the latest version uses Firebase) to handle push notifications, you need to do the following.

  1. Verify that the dependency Play-Services version is a minimum of 9.0.0. You can check this in your application build gradle configuration CustomerApplication/app/build.gradle.

    Code Block
    dependencies {
        ...
        compile 'com.vibes.vibes:vibes:1.+'
        compile "com.google.android.gms:play-services:9.0.0"
        compile 'com.google.android.gms:play-services-ads:9.0.0'
    }
    
    apply plugin: 'com.google.gms.google-services'
    Note
    Note: The (compile 'com.google.android.gms:play-services-ads:9.0.0') dependency only concerns those applications that send ads in their notifications. It is not mandatory.

    Verify that the dependency gradle version is minimum 2.3.3 and the Google-Services is version 3.0.0. You can check these in the CustomerApplication/build.gradle.

    Code Block
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
            classpath 'com.google.gms:google-services:3.0.0'
            classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    Verify that your application doesn’t use the deprecated class GooglePlayServicesUtil. The com.google.android.gms.common.GooglePlayServicesUtil has been deprecated and replaced by import com.google.android.gms.common.GoogleApiAvailability.
    If you are using it, replace the code in Code Example One below by the code in Code Example Two in your application activity (java class) where you check Google Play Services availability.
    Code Example One (CustomerApplication/[ACTIVITY_CLASS_NAME].java)
    Code Block
    import com.google.android.gms.common.GooglePlayServicesUtil; // GooglePlayServicesUtil has been deprecated
    
    ...
    
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
    if(ConnectionResult.SUCCESS != resultCode) {
        //Check type of error
        if(GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
           
     Toast.makeText(getApplicationContext(), "Google Play Service is not 
    install/enabled in this device!", Toast.LENGTH_LONG).show();
            //So notification
            GooglePlayServicesUtil.showErrorNotification(resultCode, getApplicationContext());
        } else {
           
     Toast.makeText(getApplicationContext(), "This device does not support 
    for Google Play Service!", Toast.LENGTH_LONG).show();
        }
    } else {
        //Start service
        Intent itent = new Intent(this, GCMRegistrationIntentService.class);
        startService(itent);
    }

    Code Example Two

    Code Block
    import com.google.android.gms.common.GoogleApiAvailability;
    
    ...
    
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int resultCode = googleAPI.isGooglePlayServicesAvailable(getApplicationContext());
    if (ConnectionResult.SUCCESS != resultCode) {
        //Check type of error
        if(googleAPI.isUserResolvableError(resultCode)) {
           
     Toast.makeText(getApplicationContext(), "Google Play Service is not 
    install/enabled in this device!", Toast.LENGTH_LONG).show();
            //So notification
            googleAPI.showErrorNotification(getApplicationContext(), resultCode);
        } else {
           
     Toast.makeText(getApplicationContext(), "This device does not support 
    for Google Play Service!", Toast.LENGTH_LONG).show();
        }
    } else {
        //Start service
        Intent itent = new Intent(this, GCMRegistrationIntentService.class);
        startService(itent);
    }
    If you had a deprecated version of Google Services and have followed the previous steps, the last step is to regenerate a google-services.json, then add/replace it into your App folder on https://console.firebase.google.com/.

Configuring Multiple Environments 

Build Variants

To support a separate test build from your production build in android, we recommend creating build variants for your different environments. Follow this documentation to learn more and configure build variants.

Once you have the build variants created, you can edit your build.gradle file to include your global constants for Vibes app ID and Vibes API URL.

Panel
borderWidth0

Image Added


FCM Setup 

Vibes uses Firebase Cloud Messaging (FCM) as the push transport method for Android devices that have access to the Google Play store.


CreatingFCM Server Key

  1. Log in to the Firebase console.
  2. Either create a new project or open an existing project that you want to configure with Vibes.
  3. In the left side menu, click on the gear icon and select Project settings.

    Panel
    borderWidth0

    Image Added


  4. Select Cloud Messaging tab from the the top of the screen, then copy the Server keywhich you will provide to Vibes for configuration of your application. You may also add a new server key if it is not automatically created for you or if you wish to use a different one.

    Panel

    Image Added