|
2 | 2 | <img alt="CometChat" src="https://assets.cometchat.io/website/images/logos/banner.png">
|
3 | 3 | </p>
|
4 | 4 |
|
| 5 | +# CometChat SDK for iOS |
| 6 | +The CometChat SDK is a robust toolkit that developers can utilize to swiftly incorporate a reliable and fully-featured chat functionality into an existing or new application. It removes the complexity of building a chat infrastructure from scratch, thus accelerating the development process and reducing time to market. |
5 | 7 |
|
6 |
| -# CometChat iOS Chat SDK |
7 |
| - |
8 |
| -CometChat enables you to add voice, video & text chat for your website & app. |
9 |
| -___ |
10 |
| - |
11 |
| -## Prerequisites :star: |
12 |
| - |
13 |
| -Before you begin, ensure you have met the following requirements: |
14 |
| - |
15 |
| -✅ You have installed the latest version of Xcode. (Above Xcode 12 Recommended) |
16 |
| - |
17 |
| -✅ iOS Chat SDK works for iOS devices from iOS 11 and above. |
18 |
| - |
19 |
| -___ |
20 |
| - |
21 |
| -## Installing iOS Chat SDK |
22 |
| - |
23 |
| -## 1. Setup :wrench: |
24 |
| - |
25 |
| -To install iOS Chat SDK, you need to first register on CometChat Dashboard. [Click here to sign up](https://app.cometchat.com/login). |
26 |
| - |
27 |
| -### i. Get your Application Keys :key: |
28 |
| - |
29 |
| -* Create a new app |
30 |
| -* Head over to the Quick Start or API & Auth Keys section and note the `App ID`, `Auth Key`, and `Region`. |
31 |
| ---- |
32 |
| - |
33 |
| -### ii. Add the CometChatSDK Dependency |
34 |
| - |
35 |
| - |
36 |
| -We recommend using CocoaPods, as they are the most advanced way of managing iOS project dependencies. Open a terminal window, move to your project directory, and then create a Podfile by running the following command |
37 |
| - |
38 |
| - |
39 |
| -Create podfile using below command. |
40 |
| - |
41 |
| -```bash |
42 |
| -$ pod init |
43 |
| -``` |
44 |
| -Add the following lines to the Podfile. |
45 |
| - |
46 |
| -```bash |
47 |
| -________________________________________________________________ |
48 |
| - |
49 |
| -For Xcode 12 and above: |
50 |
| - |
51 |
| -platform :ios, '11.0' |
52 |
| -use_frameworks! |
53 |
| - |
54 |
| -target 'YourApp' do |
55 |
| - pod 'CometChatSDK', '4.0.50' |
56 |
| - pod 'CometChatCallsSDK', '4.0.6' |
57 |
| -end |
58 |
| -________________________________________________________________ |
59 |
| - |
60 |
| - |
61 |
| -``` |
62 |
| -And then install the `CometChatSDK` framework through CocoaPods. |
63 |
| - |
64 |
| -```bash |
65 |
| -pod install |
66 |
| -``` |
67 |
| - |
68 |
| -If you're facing any issues while installing pods then use the below command. |
69 |
| - |
70 |
| - |
71 |
| -```bash |
72 |
| -pod install --repo-update |
73 |
| -``` |
74 |
| - |
75 |
| -___ |
76 |
| - |
77 |
| -## 2. Configure CometChat inside your app |
78 |
| - |
79 |
| -### i. Initialize CometChat :star2: |
80 |
| - |
81 |
| -The `init()` method initializes the settings required for CometChat. We suggest calling the `init()` method on app startup, preferably in the `didFinishLaunchingWithOptions()` method of the Application class. |
82 |
| - |
83 |
| -```swift |
84 |
| -import CometChatSDK |
85 |
| - |
86 |
| -class AppDelegate: UIResponder, UIApplicationDelegate{ |
87 |
| - |
88 |
| - var window: UIWindow? |
89 |
| - let appId: String = "ENTER APP ID" |
90 |
| - let region: String = "ENTER REGION CODE" |
91 |
| - |
92 |
| -func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { |
93 |
| - |
94 |
| - let mySettings = AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region: region).build() |
95 |
| - CometChat(appId: appId ,appSettings: mySettings,onSuccess: { (isSuccess) in |
96 |
| - |
97 |
| - print("CometChat SDK intialise successfully.") |
98 |
| - |
99 |
| - }) { (error) in |
100 |
| - print("CometChat SDK failed intialise with error: \(error.errorDescription)") |
101 |
| - } |
102 |
| - return true |
103 |
| - } |
104 |
| -} |
105 |
| -``` |
106 |
| -**Note :** |
107 |
| -Make sure you replace the APP_ID with your CometChat `appId` and `region` with your app region in the above code. |
108 |
| - |
109 |
| -___ |
110 |
| - |
111 |
| -### ii. Create User :bust_in_silhouette: |
112 |
| - |
113 |
| -Once initialization is successful, you will need to create a user. To create the users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created User object if the request is successful. |
114 |
| - |
115 |
| -```swift |
116 |
| - |
117 |
| -let newUser : User = User(uid: "user1", name: "Kevin") // Replace with your uid and the name for the user to be created. |
118 |
| -let authKey = "authKey" // Replace with your Auth Key. |
119 |
| -CometChat.createUser(user: newUser, apiKey: authKey, onSuccess: { (User) in |
120 |
| - print("User created successfully. \(User.stringValue())") |
121 |
| - }) { (error) in |
122 |
| - print("The error is \(String(describing: error?.description))") |
123 |
| -} |
124 |
| - |
125 |
| -``` |
126 |
| -___ |
127 |
| - |
128 |
| -### iii. Log in your User :bust_in_silhouette: |
129 |
| - |
130 |
| -The `login()` method returns the User object containing all the information of the logged-in user. |
131 |
| - |
132 |
| -```swift |
133 |
| -let uid = "SUPERHERO1" |
134 |
| -let authKey = "ENTER AUTH KEY" |
135 |
| - |
136 |
| -CometChat.login(UID: uid, apiKey: authKey, onSuccess: { (user) in |
137 |
| - |
138 |
| - print("Login successful: " + user.stringValue()) |
139 |
| - |
140 |
| -}) { (error) in |
141 |
| - |
142 |
| - print("Login failed with error: " + error.errorDescription); |
143 |
| - |
144 |
| -} |
145 |
| -``` |
146 |
| - |
147 |
| -**Note :** </br> |
148 |
| -* Make sure you replace the `authKey` with your CometChat Auth Key in the above code. |
149 |
| - |
150 |
| -* We have set up 5 users for testing having UIDs: `SUPERHERO1`, `SUPERHERO2`, `SUPERHERO3`, `SUPERHERO4`, and `SUPERHERO5`. |
151 |
| - |
152 |
| ---- |
153 |
| - |
154 |
| -# Checkout our sample apps |
155 |
| - |
156 |
| -## Swift: |
157 |
| -Visit our [Swift sample app](https://github.com/cometchat/cometchat-sample-app-ios) repo to run the Swift sample app. |
158 |
| - |
159 |
| ---- |
| 8 | +## Prerequisites |
| 9 | +- XCode (Above Xcode 12 Recommended) |
| 10 | +- iOS 11 and above |
160 | 11 |
|
| 12 | +## Getting Started |
| 13 | +To set up iOS SDK and utilize CometChat for your chat and calls functionality, you'll need to follow these steps: |
| 14 | +- Register at the [CometChat Dashboard](https://app.cometchat.com/) to create an account. |
| 15 | +- After registering, log into your CometChat account and create a new app. Once created, CometChat will generate an Auth Key and App ID for you. Keep these credentials secure as you'll need them later. |
| 16 | +- Check the [key concepts](https://www.cometchat.com/docs/sdk/ios/key-concepts) to understand the basic components of CometChat. |
| 17 | +- Refer to the [Integration Steps](https://www.cometchat.com/docs/sdk/ios/setup) in our documentation to integrate the SDK into your i app. |
161 | 18 |
|
162 | 19 | ## Help and Support
|
163 |
| -For issues running the project or integrating with our UI Kits, consult our [documentation](https://www.cometchat.com/docs/react-uikit/integration) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/). |
164 |
| - |
165 |
| - |
| 20 | +For issues running the project or integrating with our SDK, consult our [documentation](https://www.cometchat.com/docs/sdk/ios/overview) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/). |
0 commit comments