Coder Social home page Coder Social logo

quickblox-android-sdk's Introduction

QuickBlox

QuickBlox - Communication & cloud backend (BaaS) platform which brings superpowers to mobile apps.

QuickBlox is a suite of communication features & data services (APIs, SDKs, code samples, admin panel, tutorials) which help digital agencies, mobile developers and publishers to add great functionality to smartphone applications.

Please read full Android SDK documentation on the QuickBlox website, Android section

QuickBlox Android SDK

This project contains QuickBlox Android SDK, that includes

How to start

To start work you should just put framework into your project and call desired methods.

Latest framework file you can download from GitHub.

Documentation

Oh, please, please show me the code

Android SDK is really simple to use. Just in few minutes you can power your mobile app with huge amount of awesome communication features & data services.

1. Get app credentials

2. Create new Android project

3. Add jar library to project libs folder.

Eclipse users: If you got 'Unable to execute dex: Java heap size' - try to upgrade eclipse.ini to https://groups.google.com/forum/?fromgroups=#!topic/phonegap/yWePvssyiLE

4. Declare internet permission for Android application

  • Go to AndroidManifest.xml and add
<uses-permission android:name="android.permission.INTERNET" />

inside <manifest> tag.

5. Make QuickBlox API calls

The common way to interact with QuickBlox can be presented with following sequence of actions:

  1. Initialize framework with application credentials
  2. Create session
  3. Login with existing user or register new one
  4. Perform actions with any QuickBlox data entities (users, locations, files, custom objects, pushes etc.)

5.1 Initialize framework with application credentials

QBSettings.getInstance().fastConfigInit("961", "PBZxXW3WgGZtFZv", "vvHjRbVFF6mmeyJ");

or step by step

QBSettings.getInstance().setApplicationId("961");
QBSettings.getInstance().setAuthorizationKey("PBZxXW3WgGZtFZv");
QBSettings.getInstance().setAuthorizationSecret("vvHjRbVFF6mmeyJ");

5.2. Create session

QBAuth.createSession(new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // do stuff you need
        }
    }
});

5.3. Register/login

First create (register) new user

// Register new user
QBUsers.signUp("indianajones", "indianapassword", new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // result comes here if request has been completed successfully
        }
    }
});

then authorize user

// Login
QBUsers.signIn("indianajones", "indianapassword", new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // result comes here if request has been completed successfully
        }
    }
});

to authorise user in Chat

// initialize SMACK
SmackAndroid.init(this);

final QBUser user = new QBUser("indianajones", "indianapassword");
// login to Chat
QBChatService.getInstance().loginWithUser(user, new SessionListener() {
    @Override
    public void onLoginSuccess() {
        Log.d(TAG, "success when login");
    }

    @Override
    public void onLoginError() {
        Log.e(TAG, "error when login");
    }

    @Override
    public void onDisconnect() {
        Log.d(TAG, "disconnect when login");
    }

    @Override
    public void onDisconnectOnError(Exception exc) {
        Log.e(TAG, "disconnect error when login", exc);
    }
});

5.4. Perform actions

Send Chat message

// Create 1-1 chat
QBPrivateChat chat = QBChatService.getInstance().createChat();
chat.addChatMessageListener(new ChatMessageListener() {
    @Override
    public void processMessage(Message message) {
        Log.d(TAG, "Messags: " + message.getBody());
    }

    @Override
    public boolean accept(Message.Type type) {
        switch (messageType) {
            case chat:
                return true; // process 1-1 chat messages
            default:
                return false;
        }
    }
});

// send message
chat.sendMessage(546, "Hi mate!");

Create new location for Indiana Jones

double lat = 25.224820; // Somewhere in Africa
double lng = 9.272461;
String statusText = "trying to find adventures";
QBLocation location = new QBLocation(lat, lng, statusText);
QBLocations.createLocation(location, new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // result comes here if authorizations is success
        }
    }
});

or put Holy Grail into storage

File file = new File("holy_grail.txt");
Boolean fileIsPublic = true;
QBContent.uploadFileTask(file, fileIsPublic, new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // file has been successfully uploaded
        }
    }
});

Java Framework provides following services to interact with QuickBlox functions (each service is represented by model with suite of static methods):

  • QBAuth
  • QBUsers
  • QBChatService
  • QBCustomObjects
  • QBLocations
  • QBContent
  • QBRatings
  • QBMessages

See also

quickblox-android-sdk's People

Contributors

ishaforenko avatar alisandr avatar sergey-fedunets avatar vfite avatar andrii-dmytrenko avatar dmitripiryatenets avatar

Watchers

 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.