Giter Site home page Giter Site logo

webim-android-sdk-demo's Introduction

Webim SDK sample

A sample for represent interaction with Webim Mobile SDK. Supported from Android API 15

Version

Download

Installation

Add to your build.gradle dependencies:

compile 'com.webim.sdk:webimclientsdkandroid:2+'

May require (SDK is using this libraries. By default, they will be added to your project automatically, but in special cases you need to add them manually):

compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'

Required permission:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Usage

WebimSdk contains 2 types of session:

  • Online chat (WMSession)
  • Offline chats (WMOfflineSession)
Important!

Not guaranteed stable work with retrofit 2.0.0-beta or higher.

If a user needs an immediate response from an operator, please, use Online chat.

If a user just leave request, and an operator can answer later (e.g. in one week), please, use Offline chats.

Development

#####Online chat Online chats are simpler for implementation. You can see example in OnlineChatFragment. All you need is:

  • Create WMSession.WMSessionDelegate.
  • Overwrite event methods (e.g. sessionDidChangeSessionStatus, sessionDidStartChat, sessionDidReceiveMessage and others)
  • Create WMSession using Android Context, Webim account and location (please, contact Webim Support for more info about this params), and WMSessionDelegate.
  • Call startSession() from WMSession object.

After this steps, you will receive events in WMSessionDelegate and can perform any actions with WMObjects(WMChat, WMOperator, WMMessage and e.t.c.).

For interaction with Online Chat uses other methods from WMSession (e.g. startChat, sendMessage, sendImage, closeChat and others).

If you want to stop communication with Webim service, please, call stopSession (e.g onStop() or onDestroy()).

#####Offline Chats WMOfflineSession can contain 0+ chats.

So, default imp is containing 2 Views

  • Chats Chooser View (OfflineFragment)
  • Chat View (OfflineChatFragment)

Creation of WMOfflineSession is the same as WMSession, but it doesn't contain global delegate.

  • To receive cached data use method getOfflineChats()
  • To receive last data from server use getHistoryForced() (boolean param forced means that data will be updated from beginning of the session. Please use cached data with forced = false - this will reduce internet traffic, and request only last changes from server.)
  • Each request has its own callback (sendMessage, sendImage, deleteCaht and e.t.c.), so you can interact with them separately.

Offline chat can create messages and chats locally, without an internet connection. For sync data with Webim Service please use method sendUnsentRequests from WMOfflineSession.

###Push Notification By default, online and offline sessions have GCM interaction.

For enable push-notification system, please add default realization See android samples and GcmIntentService with GcmBroadcastReceiver.

To make WebimSdk collaborate with push call static method WMSession.onPushMessage (see GcmIntentService). Don't forget about requirement of permissions for GCM.

Todo's

  • Add info about "Synchronized requests" in WMOfflineChats.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

webim-android-sdk-demo's People

Contributors

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