Giter VIP home page Giter VIP logo

blip-teste's Introduction

Introduction

SDK to easily add Blip Chat's widget to your iOS app. For more information, see Blip documentation.


Getting Started

  1. First thing you need to do, is add Blip SDK to the project. To do this, you need to modify your PodFile, adding the lines bellow:
use_frameworks!

pod 'blip-sdk-ios', :git => 'https://github.com/takenet/blip-chat-sdk-ios'

  1. After that, run the bellow command, to install the new dependecy:
pod install

  1. Now, you have to inherit BlipChatDelegate in your AppDelegate file:
class AppDelegate: BlipChatDelegate {

    override func application(_ application: UIApplication, didFinishLaunchingWithOptions
        launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        return true
    }
}

  1. Last but not least, you have to create a new instance of BlipChat. In the ViewController responsible to open the chat page. Create a call action according to the sample bellow:
let chat = BlipChat()

chat.onMessageReceived = { (message: String) in
    print(message)
}

let model = BlipChatModel(
    key: "{YOUR_OWNER_KEY}",
    type: "plain",
    account: BlipChatAccountModel(
        fullName: "{LOGGED_USER_FULL_NAME}",
        photoUri: "{LOGGED_USER_AVATAR_URI}",
        pushToken: "{DEVICE_PUSH_NOTIFICATION_TOKEN}",
    ),
    style: BlipChatStyleModel(
        primary: "02AFFF",
        sentBubble: "FFFFFF",
        receivedBubble: "02AFFF",
        background: "EFEFEF",
        overrideOwnerColors: true,
        showUserAvatar: false
    )
)

chat.show(blipChatModel: model, viewController: self)

Properties

BlipChatModel

Property Required Description Type
key YES String key that identifies the owner String
type YES Indicates the authentication type, used to sign in the user AuthenticationTypeEnum
token NO* User token used to identity the application logged user. Used with external type only String
issuer NO* Issuer used to authenticate session. Used with external type only String
hostName NO Custom hostName used to connect to Blip Server String
useMtls NO Determines if the connection will use mTLS for avoid MITM attacks. Default: false bool
account NO Logged user account data BlipChatAccountModel
style NO Custom chat style BlipChatStyleModel

* Required for external authentication type.

BlipChat Account

Property Required Description Type
pushToken NO Logged user's device push notification Token String
fullName NO Logged user full name to be stored on Blip Account String
email NO Logged user email to be stored on Blip Account String
photoUri NO Logged user avatar uri to be stored on Blip Account String
encryptMessageContent NO Determines if the message content will be encrypted bool

BlipChat Style

Property Required Description Type
primary NO Primary chat HEX color String
sentBubble NO Sent message bubble HEX color String
receivedBubble NO Received message bubble HEX color String
background NO Chat background HEX color String
overrideOwnerColors NO Determines if the colors sent in this object, will override the owner configuration colors. Default: false bool
showOwnerAvatar NO Determines if the owner avatar will be shown. Default: true bool
showUserAvatar NO Determines if the user avatar will be shown. Default: true bool

Authentication Type

Property Description
plain Plain text authentication method
external External authentication method. For this authentication type, is necessary to send token and issuer properties

Authentication

It's possible to authenticate with two different methods, plain and external.

Plain

Plain authentication is the most commom authentication method and it's probably the one you should use. In this method, Blip manage the user, so you don't need to worry. See an example below of how to authenticate with plain type:

let model = BlipChatModel(
    key: "{YOUR_OWNER_KEY}",
    type: "plain",
    account: BlipChatAccountModel(
        pushToken: "{DEVICE_PUSH_NOTIFICATION_TOKEN}",
    ),
    style: BlipChatStyleModel(
        showUserAvatar: false
    )
)

External

External authentication is commonly used when you have your own authentication provider. However, to use your own provider, it's necessary to contact us, in order to integrate Blip with it. See an example below of how to authenticate with external type:

let model = BlipChatModel(
    key: "{YOUR_OWNER_KEY}",
    type: "external",
    token: "{LOGGED_USER_AUTH_TOKEN}",
    issuer: "{YOUR_CUSTOM_AUTH_ISSUER}",
    account: BlipChatAccountModel(
        pushToken: "{DEVICE_PUSH_NOTIFICATION_TOKEN}",
    ),
    style: BlipChatStyleModel(
        showUserAvatar: false
    )
)

UseMtls

The property useMtls is used to avoid MITM attacks. In most use cases, should be set to false. However, if you need this extra security check, it's necessary to pass a hostName that supports mTLS authentication. Contact us to get your mTLS hostName.

Observers

Event Name Params
onInitializing message: String
onConnected message: String
onReady message: String
onMessageReceived message: String
onMessageSend message: String
onMessageViewed message: String
onDisconnected message: String
onClosed -
onError error: String

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.

blip-teste's People

Contributors

hugolrf avatar

Watchers

 avatar

Forkers

markus-shmidt

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.