SDK to easily add Blip Chat's widget to your iOS app. For more information, see Blip documentation.
- 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'
- After that, run the bellow command, to install the new dependecy:
pod install
- Now, you have to inherit
BlipChatDelegate
in yourAppDelegate
file:
class AppDelegate: BlipChatDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
}
- Last but not least, you have to create a new instance of
BlipChat
. In theViewController
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)
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.
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 |
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 |
Property | Description |
---|---|
plain |
Plain text authentication method |
external |
External authentication method. For this authentication type, is necessary to send token and issuer properties |
It's possible to authenticate with two different methods, plain
and external
.
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
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
)
)
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
.
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 |
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.