Android sdk


Мы предаставляем нативное андроид сдк, с помощью которого вы можете организовать всестороннюю поддержку ваших польхователей. С возможностью показа фака и контакта с сапортом по средствам онлайн\оффлайн чата. С пуш нотификациями и логированием действий пользователя.



Installation



If you using Android studio


1. Add jcenter as a repo to your main build.gradle

repositories {
    jcenter()
}

2. Add ru.apps-m:inapphelp:0.3.2 as a dependency to your app build.gradle

dependencies {
    compile 'ru.apps-m:inapphelp:0.3.2'
}

If you have issue "Duplicate files copied": just exclude duplicates. Add this to your "android" gradle tag

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}

If you using Eclipse/ADT


1. Download release from git: https://github.com/apps-m/inapphelp-android/releases

2. Set the flag for manifestmerger.enabled to true in your project.properties file:

manifestmerger.enabled=true

If you have error "Jar mismatch! Found different versions of jar in the dependency list:": Replace the jar in the library with the jar from your project.



Integration


Initializing


We identifies your App with three params:

App id    - Unique app id.

App key - Unique app key.

Domain - Your inapphelp company domain name.

To get this params navigate to Settings -> integration in your admin panel.

To initialize inapphelp, call init method in the onCreate of your Application class.

package com.test;
import android.app.Application;
import ru.appsm.inapphelp.IAHHelpDesk;

public class MainApplication extends Application {
    @Override
    public void onCreate(){
        super.onCreate();
        IAHHelpDesk.init(this, "company", "appid", "appkey");
    }
}

Also, you can set your custom user id (To identificate user in your system).

IAHHelpDesk.setUserId("userid");

And user secret key, to allow issues only from signed users.Secret key it is userid signed by your own server. Learn more about secure concept

IAHHelpDesk.setUserSecret("secretkey");

Using


To show help use showHelp() api call. Example:

button.setOnClickListener(new Button.OnClickListener() {
    @Override
    public void onClick(View v) {
        IAHHelpDesk.showHelp(MainActivity.this);
    }
});

Push notifications


First, implement google gcm notification in your app. Documentation. Also you can refer to our sample app on github.


After earn push notification token - send it on backend

IAHHelpDesk.setPushToken(token);

Then configure your app settings in admin panel. Go to your admin panel - > settings -> applications and click on the app. Set android push notification state to 'On', and provide your GCM Api Key and Bundle ID.


And finally, don't forget to handle push notification receive event. In your “GcmIntentService” in onHandleIntent method check extras "source" param is “inapphelp” and pass the intent to our API: IAHHelpDesk.HandelPushIntentWithContext(intent, Context);

Example:

@Override
protected void onHandleIntent(Intent intent) {

    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {  // has effect of unparcelling Bundle
        /*
        * Filter messages based on message type. Since it is likely that GCM will be
        * extended in the future with new message types, just ignore any message types you're
        * not interested in, or that you don't recognize.
        */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            //sendNotification("Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            //sendNotification("Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            String source = extras.getString("source");
            if ((source != null) && source.equals("inapphelp")) {
                //Notification from inapphelp.
                IAHHelpDesk.HandelPushIntentWithContext(intent, getApplicationContext());
            } else {
                //Notification not from inapphelp. Do your own logic there.
            }
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}