Git Product home page Git Product logo

anachat-android's Introduction

ANAChat Android

The Powerful ANAchat android SDK allows you to integrate ANA to your app in two simple steps. Customise the UI according to your App Theme and you are all set. It is that simple!


Getting started

Add below mandatory dependencies in your app level build.gradle.

    dependencies {
    ...
    compile 'com.kitsune:anachatsdk:1.2.20@aar'
    compile 'com.android.support:design:26.1.0'
    compile 'com.j256.ormlite:ormlite-android:5.0'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'com.github.bumptech.glide:glide:4.1.1'
    ...
    }

FCM configuration is required to use this SDK please check the documentation here to configure.

After successful configuration of FCM, Modify below classes:

In FirebaseInstanceIdService public class AnaChatBotInstanceIDService extends FirebaseInstanceIdService {

@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    //If(user is not registered)
    AnaCore.saveFcmToken(this, refreshedToken);
    else
    AnaCore.saveFcmToken(this, refreshedToken,"user_id");
    }
}

In FirebaseMessagingService public class AnaChatBotMessagingService extends FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    Map<String, String> mapResult = remoteMessage.getData();
    if (mapResult.containsKey("payload")) {
        AnaCore.handlePush(this, mapResult.get("payload"));
    }

}
}

Register user after your login flow: AnaCore.registerUser(context, "your_user_id", YOUR_BUSINESSID, YOUR_BASE_URL);

To unregister user: AnaCore.logoutUser(context);

**Add permissions In manifest**

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


 **Start BOT**

             new AnaChatBuilder(activity)
                .setBusinessId("your_businessId")
                .setBaseUrl("your_base_url")
                .setThemeColor(R.color.primary)
                .setToolBarDescription("Your Toolbar desc")
                .setToolBarTittle("Your Tittle")
                .setToolBarLogo(R.drawable.ic_your_logo)
          (optional).registerLocationSelectListener(this)
                .setFlowId(YOUR_FLOW_ID)
                .start();

Note: Pass Valid businessId and BaseUrl in builder.

OPTIONAL :- To enable Location support in SDK follow below steps:

  1. Register or Login here to get places api key.

  2. add google places key in manifest file under application tag. <meta-data android:name="com.google.android.geo.API_KEY" android:value="your_key" />

  3. addcompile'com.google.android.gms:play-services-places:11.6.0'in app level gradle file.

  4. implement LocationPickListener in your fragment/activity.

  5. add registerLocationSelectListener(this) in AnaChatBuilder.

  6. Override methods and Paste below code :-

    @Override
     public Intent pickLocation(Activity activity) {
         try {
             PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
             Intent placePickerIntent = builder.build(activity);
             placePickerIntent.putExtra("primary_color",
                     Color.parseColor(PreferencesManager.getsInstance(activity).getThemeColor()));
             placePickerIntent.putExtra("primary_color_dark",
                     ContextCompat.getColor(activity, R.color.gray_light));
             return placePickerIntent;
         } catch (GooglePlayServicesRepairableException |
                 GooglePlayServicesNotAvailableException e) {
             e.printStackTrace();
         }
         return null;
     }
    
     @Override
     public void sendLocation(Intent data) {
         Place place = PlacePicker.getPlace(this, data);
         LatLng latLng = place.getLatLng();
         AnaCore.sendLocation(latLng.latitude, latLng.longitude, this);
     }

Proguard :- Please check & paste configuration from here

License

ANA Conversation Suite is available under the GNU GPLv3 license.

anachat-android's People

Watchers

 avatar  avatar

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.