Versions Compared

Key

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

The latest Vibes Push Notifications Android SDK installation instructions are also located in the Vibes SDK repository .

Vibes SDK - Android

...

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

...

  1. Click Add Firebase Cloud Messaging and follow the instructions. This will include adding two services to your

...

  1. app to handle

...

  1. app token refresh and incoming push notifications.

...

...

  1. Add the Vibes SDK by doing the following:

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

      Code Block
      maven {
      

...

    1.     url "https://raw.githubusercontent.com/

...

    1. vibes/

...

    1. android-sdk-

...

    1. repository/releases/"

...

    1. 
      

...

    1. }

...


    1. Add the following to your

...

Code Block
VIBES_GITHUB_USERNAME=your-github-username-here
VIBES_GITHUB_PASSWORD=your-github-password-or-personal-access-token-here
Note
Note: Do not commit this file to version control.

...

    1. app-level build.gradle file:

      Code Block
      dependencies {
      

...

    1.    // other dependencies here

...

    1.  

...

    1.    
      	implementation "com.vibes.vibes:vibes:

...

    1. 4.

...

    1. 4.

...

    1. 3"
      }

       

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

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

Code Block
dependencies {
    ...
    compile 'com.vibes.vibes:vibes:2.0.0'
    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'

Verify that the dependency gradle version is minimum 2.3.3 and the Google-Services is version 3.0.0. You can check that 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
    }
}

...

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);
}

...

Tests

You can run the tests from within Android Studio, or via the command line with ./bin/test.

Test results live in, vibes/build/reports/tests/testDebugUnitTest/.

Setup

Configure your root- or system-level gradle.properties file with your Github username and either a password or a personal access token (see the sample file for format).

To Release

Bump the ARTIFACT_VERSION in the vibes/gradle.properties file. Then run:

...

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