|
1 |
| -The following documentation is built to help you with installing our iOS SDK into your project. The following documentation is built to help you with installing our iOS SDK into your project. |
2 |
| - |
3 |
| -The Channelize SDK can be installed using the following method The Channelize SDK can be installed using the following method |
4 |
| - |
5 |
| -Firstly, you will need to register on Channelize: https://channelize.io/pricing |
6 |
| - |
7 |
| - After the successful payment at https://channelize.io/pricing you'll get the zip file file that will contains the all messaging and other feature of channelize.io. |
8 |
| - |
9 |
| -- Extract Zip File |
10 |
| -- You will get the `PrimeMessenger.framework` file. |
11 |
| -- Copy and paste it in your project directory. |
12 |
| -- Drag and drop it in the `Embedded Binaries` section of your project as described in the below image. |
13 |
| - |
14 |
| -ScreenShot url: |
15 |
| - |
16 |
| - |
17 |
| -## Dependencies |
18 |
| -**Requirement** |
19 |
| - |
20 |
| - Before we begin, please do make sure that |
21 |
| - |
22 |
| -- Your application is built on iOS 9.0 or above. Since Channelize SDK as of now only supports Version 9.0 or higher. |
23 |
| -- You have Xcode 9.4.1 or later as your IDE to install and run Channelize SDK on iOS. |
24 |
| -- Swift 4.2 |
25 |
| - |
26 |
| - **Pod Installation** |
27 |
| - |
28 |
| - - You need to install few dependancy pods just after you are done coyping SDK in you project otherwise the project will not compile. |
29 |
| - ```xml |
30 |
| - pod 'MQTTClient', '0.15.2' |
31 |
| - pod 'MQTTClient/Websocket', '0.15.2' |
32 |
| - pod 'Alamofire', '4.8.0' |
33 |
| - pod 'AlamofireObjectMapper', '5.2.0' |
34 |
| - pod 'Gallery' , '2.2.0' |
35 |
| - pod 'Hue' , '4.0.0' |
36 |
| - pod 'Lightbox', '2.3.0' |
37 |
| - pod 'SwiftIconFont', '3.0.0' |
38 |
| - pod 'ZVProgressHUD', '2.0.3' |
39 |
| - pod 'CWStatusBarNotification', '2.3.5' |
40 |
| - pod 'GiphyCoreSDK', '1.4.0' |
41 |
| - pod 'Chatto', :git => 'https://github.com/BigStepTechnologies/Chatto', :branch => 'update/v1.0' |
42 |
| - pod 'ChattoAdditions', :git => 'https://github.com/BigStepTechnologies/Chatto', :branch => 'update/v1.0' |
43 |
| - pod 'InputBarAccessoryView' , '4.2.1' |
44 |
| - pod 'SDWebImage/GIF', '4.4.3' |
45 |
| -# this pod is required if you have video and voice call module enabled |
46 |
| - pod 'AgoraRtcEngine_iOS', '2.3.1' |
47 |
| - |
48 |
| - ``` |
49 |
| - - Run `pod install` after setting up pods in your peoject. |
50 |
| - |
51 |
| - |
52 |
| - ## Configuration |
53 |
| - |
54 |
| - **Step 1** - Create a file with name PrimeMessenger-Info.plist or download already created file from here [Config File](https://github.com/ChannelizeIO/Channelize-iOS/blob/master/demo/demo/PrimeMessenger-Info.plist) |
55 |
| - |
56 |
| - **Step 2** - Place all the required keys in the PrimeMessenger-Info.plist file. |
57 |
| - |
58 |
| - **Step 3** - You also need to create the language string file with name PrimeLocalizable.strings. [Language File](https://github.com/ChannelizeIO/Channelize-iOS/blob/master/demo/demo/PrimeLocalizable.strings) |
59 |
| - |
60 |
| - **Step 4** - Make sure you have the following permissions in your `Info.plist` file |
61 |
| - |
62 |
| - ```xml |
63 |
| -<key>NSAppTransportSecurity</key> |
64 |
| - <dict> |
65 |
| - <key>NSAllowsArbitraryLoads</key> |
66 |
| - <true/> |
67 |
| - </dict> |
68 |
| - <key>NSCameraUsageDescription</key> |
69 |
| - <string>You can take photos to document your job.</string> |
70 |
| - <key>NSLocationAlwaysUsageDescription</key> |
71 |
| - <string>This app wants to access your location</string> |
72 |
| - <key>NSLocationWhenInUseUsageDescription</key> |
73 |
| - <string>This app wants to access your location</string> |
74 |
| - <key>NSPhotoLibraryUsageDescription</key> |
75 |
| - <string>You can select photos to attach to reports.</string> |
76 |
| - <key>NSMicrophoneUsageDescription</key> |
77 |
| - <string>Microphone to start a call</string> |
78 |
| - <key>UIBackgroundModes</key> |
79 |
| - <array> |
80 |
| - <string>voip</string> |
81 |
| - </array> |
82 |
| -``` |
83 |
| - |
84 |
| - ## Voip notification setup |
85 |
| - |
86 |
| - - You need to copy the [CallProvider](https://github.com/ChannelizeIO/Channelize-iOS/blob/master/demo/demo/CHCallProvider.swift) and paste it in your project directory |
87 |
| - - Add the following code in your ` AppDelegate.swift ` file |
88 |
| - ```swift |
89 |
| - extension AppDelegate: PKPushRegistryDelegate { |
90 |
| - |
91 |
| - func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) { |
92 |
| - |
93 |
| - let deviceToken = credentials.token.reduce("", {$0 + String(format: "%02X", $1) }) |
94 |
| - debugPrint("Voip Token - ",deviceToken) |
95 |
| - PrimeMessenger.updateVoipToken(token: deviceToken) |
96 |
| - } |
97 |
| - |
98 |
| - func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) { |
99 |
| - |
100 |
| - print("\(#function) incoming voip notfication: \(payload.dictionaryPayload)") |
101 |
| - if let callId = payload.dictionaryPayload["callId"] as? String,let uid = payload.dictionaryPayload["userId"] as? String { |
102 |
| - let uuid = UUID() |
103 |
| - let call = PMActiveCall(uuid: uuid, callId: callId, uid: uid) |
104 |
| - call.displayName = payload.dictionaryPayload["displayName"] as? String |
105 |
| - call.profileImageUrl = payload.dictionaryPayload["profileImageUrl"] as? String |
106 |
| - if let callType = payload.dictionaryPayload["type"] as? String,callType == "video" { |
107 |
| - call.type = .video |
108 |
| - } |
109 |
| - |
110 |
| - // display incoming call UI when receiving incoming voip notification |
111 |
| - let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil) |
112 |
| - self.displayIncomingCall(call: call) { _ in |
113 |
| - UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier) |
114 |
| - } |
115 |
| - |
116 |
| - } |
117 |
| - } |
118 |
| - |
119 |
| - func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) { |
120 |
| - print("\(#function) token invalidated") |
121 |
| - } |
122 |
| - |
123 |
| - // Display the incoming call to the user |
124 |
| - func displayIncomingCall(call: PMActiveCall, completion: ((NSError?) -> Void)? = nil) { |
125 |
| - callProvider?.reportIncomingCall(of: call) |
126 |
| - } |
127 |
| - |
128 |
| -} |
129 |
| - ``` |
130 |
| - - Create the following variables in your project's `AppDelegate.swift` file |
131 |
| - ```swift |
132 |
| - let pushRegistry = PKPushRegistry(queue: DispatchQueue.main) |
133 |
| - var callProvider: CHCallProvider? |
134 |
| - ``` |
135 |
| - - Place the following code in ` didFinishLaunchingWithOptions ` function of your project's `AppDelegate.swift` file |
136 |
| - ```swift |
137 |
| - |
138 |
| - pushRegistry.delegate = self |
139 |
| - pushRegistry.desiredPushTypes = [.voIP] |
140 |
| - |
141 |
| - callProvider = CHCallProvider() |
142 |
| - |
143 |
| - ``` |
144 |
| - |
145 |
| - ## Integration |
146 |
| - |
147 |
| - Here are the few steps that you need to follow for integrating Channelize with your application. It includes configuring & launching Channelize. |
148 |
| - |
149 |
| - **Configuring Channelize** |
150 |
| - |
151 |
| - - To configure Channelize you need to add the following code in `didFinishLaunchingWithOptions` function of your project's `AppDelegate.swift` file |
152 |
| - |
153 |
| - ```swift |
154 |
| - PrimeMessenger.configure() |
155 |
| - ``` |
156 |
| - - To add theme color in Channelize sdk you need to add the following code in `didFinishLaunchingWithOptions` function of your project's `AppDelegate.swift` file |
157 |
| - |
158 |
| - ```swift |
159 |
| - appDefaultColor = "YOUR_APP'S_THEME_COLOR" |
160 |
| - ``` |
161 |
| - |
162 |
| - **Launching Channelize** |
163 |
| - - You need to **login** first before launching channelize by adding the following code on login button action |
164 |
| - ```swift |
165 |
| - PrimeMessenger.app.login(username: email, password: password){(status) in |
166 |
| - if(status){ |
167 |
| - if let navigationController = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController{ |
168 |
| - navigationController.setNavigationBarHidden(true, animated: false) |
169 |
| - PrimeMessenger.app.openMessenger(navigationController: navigationController, |
170 |
| - data: nil) |
171 |
| - } |
172 |
| - } |
173 |
| - } |
174 |
| - |
175 |
| - ``` |
176 |
| - - For **launching** channelize from your app you need to to call the following code for the action you want to launch Channelize on |
177 |
| - |
178 |
| - ```swift |
179 |
| - if(PrimeMessenger.currentUserId() != nil){ |
180 |
| - if let navigationController = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController{ |
181 |
| - navigationController.setNavigationBarHidden(true, animated: false) |
182 |
| - PrimeMessenger.app.openMessenger(navigationController: navigationController, |
183 |
| - data: nil) |
184 |
| - } |
185 |
| - } |
186 |
| - ``` |
187 |
| - |
188 |
| - - For performing **Logout** action you need to add the following code |
189 |
| - ```swift |
190 |
| - PrimeMessenger.logout() |
191 |
| - ``` |
192 |
| - - For **launching Conversation Screen** for a **specific user** - |
193 |
| - *User id should be integer |
194 |
| - ```swift |
195 |
| -let data = [AnyHashable("userId"):"SPECIFIC_USER_ID"] |
196 |
| -if let navigationController = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController{ |
197 |
| - PrimeMessenger.app.openMessenger(navigationController: navigationController, data:data) |
198 |
| -} |
199 |
| - ``` |
200 |
| - - For setting up user online and offline |
201 |
| -```swift |
202 |
| -PrimeMessenger.setUserOnline(completion: {(status,error) in |
203 |
| - if let returnedError = error{ |
204 |
| - print(returnedError.localizedDescription) |
205 |
| - debugPrint("User status update operation Failed") |
206 |
| - } else if status != nil{ |
207 |
| - debugPrint("User status update operation Complete") |
208 |
| - } |
209 |
| -}) |
210 |
| -``` |
211 |
| - |
212 |
| - ```swift |
213 |
| -PrimeMessenger.setUserOffline(completion: {(status,error) in |
214 |
| - if let returnedError = error{ |
215 |
| - print(returnedError.localizedDescription) |
216 |
| - debugPrint("User status update operation Failed") |
217 |
| - } else if status != nil{ |
218 |
| - debugPrint("User status update operation Complete") |
219 |
| - } |
220 |
| -}) |
221 |
| - ``` |
222 |
| - ## Note:- |
223 |
| - - Voip integration required if in case client has Video and voice calls integrated. |
224 |
| - - Voip permission in info.plist file required if in case client has Video and voice calls integrated. |
225 |
| - - pod 'AgoraRtcEngine_iOS', '2.3.1' required if in case client has Video and voice calls integrated. |
| 1 | +This sample app demonstrates how to build a real-time messaging iOS App using [Channelize.io](https://channelize.io) iOS SDKs. Refer our [iOS Developer Documentation](https://docs.channelize.io/) to know steps to install, configure and use it. |
0 commit comments