Chat

  • You will need the Channel key of the project, which is the key that our system uses to identify it, so it is unique for each project.
  • Xcode
    * An iOS device to run the app

Integration

This article shows the minimum development that must be done to start registering devices and being able to carry out the first push campaigns.

Adding the Chat dependencies
Chat is available through CocoaPods.

CocoaPods is a valid dependency manager for Swift and Objective-C, being the most popular in iOS development.

If you don't have it yet, install CocoaPods. Open your terminal and run the following commands:

$ cd /ROOT/OF/YOUR/PROJECT
$ gem install cocoapods
$ pod init

To integrate the Chat of indigitall it is necessary to add the following dependencies:

  • The SocketIO-client library
  • Indigitall's Chat

Modify the PodFile file of your project and add this code:

target '<YourTarget>' do
    pod 'indigitall-ios-chat'
end

🚧

Remember

Add the corresponding pod of the Chat inside the names of the target that your application has.

Update the CocoaPod repository and install the dependencies from the terminal:

$ pod repo update
$ pod install

🚧

Attention

From here you must use .workspace instead of .xcproject to work on the project.
The main difference is that .xcproject is for a single project and .workspace can contain multiple projects.

Initialize Chat

To initialize the Chat it is necessary to add a UIView object that refers to IndigitallChatView in the Identity Inspector of the side menu, where the Chat will be displayed. We must add the following lines of code:

1176
  • channelKey is an alphanumeric string that identifies your indigitall project.

The following fields are custom. If they are not added, the Chat will show the default values.

* externalKey is a string that identifies each device.

  • titleChat It is a string with the title that you want to be shown in the chat.
  • botName is a string with the name of the bot that will be displayed above the bubble on the left side.
  • defaultUserName It is a string with the default name that the user will have and will be displayed above the user's bubble.
  • messagePlaceholder It is a string with the message that is displayed in the text field where it must be written.
  • openFileText It is a string with the text that will be displayed in the case a file has to be downloaded.
  • backgroundChatColor is a string with the chat background color in hexadecimal or object color.
  • backgroundBarColor is a string with the background color of the upper and lower bars in hexadecimal or object color.
  • primaryColor is a string with the main color of the chat, buttons and floating icon in hexadecimal or object color.
    * fullscreen is a boolean where you indicate if you want the chat to occupy the entire screen (true) or have a certain margin of the device (false).
  • defaultChatIconResource is a reference with the icon resource taht show on the chat main icon.
  • addContactTextButton is a string with the message text to add a contact.
  • contactAddedMessage is a string with the message when you added a new contact.
  • infoContactIconsColor is a string with the color of the icons of info contact view
  • infoContactTopBarTitle is a string top bar title of info contact view.
  • chatAutoOpenTime is an integer that indicates the seconds for the chat to open automatically. If no chatAutoOpenTime is specified, such as if you press the bubble before the specified time expires, the chat can be opened manually.

To be able to perform actions when the Chat is shown or hidden, you can implement the event handlers or protocols, first you must define the viewController as a delegate and then add the protocol interfaces:

class ViewController: UIViewController, OnChatProtocol{
  ...
    @IBOutlet weak var indigitallChatView: IndigitallChatView!{
        didSet{
            indigitallChatView.chatProtocol = ChatProtocol.init()
            indigitallChatView.chatProtocol.setDelegate(self)
        }
    }

   func onChatShown() {
      //Do Something
    }

    func onChatHidden() {
      //Do Something
    }
}
@interface ViewController : UIViewController<OnChatProtocol>{
  @property (weak, nonatomic) IBOutlet IndigitallChatView *indigitallChatView;
  ....
}
@implementation ViewController{

  - (void) setIndigitallChatView: (IndigitallChatView *)indigitallChatView{
      indigitallChatView.chatProtocol = [[ChatProtocol alloc]init];
      [indigitallChatView.chatProtocol setDelegate: self];
  }

  - (void) onChatShown(){
    //Do Something
  }

  - (void) onChatHidden(){
    //Do Something
  }
}

Changelog

[1.3.0] - 01/2022
Added

  • Interactive Field
  • Automatically open chat option

[1.2.0] - 11/2021
Added

  • Show info contact and location option

[1.1.0] - 06/2021
Added
Added template with buttons and pdf

[1.0.1] - 01/2021
Added

  • Unity test

[1.0.0] - 11/2020
Added

  • Init