### Session Creation Example Source: https://github.com/webim/webim-client-sdk-ios/blob/master/README.md Example of creating a Webim session using the newSessionBuilder method. ```swift let webimSession = try Webim.newSessionBuilder().set(accountName: "ACCOUNT_NAME").set(location: "LOCATION_NAME").build() ``` -------------------------------- ### Device Token Conversion Example Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Example code to convert a device token to the required hexadecimal string format. ```swift let deviceToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined() ``` -------------------------------- ### Remote Notification Handling Example Source: https://github.com/webim/webim-client-sdk-ios/blob/master/README.md Example of how to define remote notification strings in a Strings.localizable file for iOS. ```swift "P.OM" = "Message from %@ is received: %@." ``` -------------------------------- ### Carthage Installation Source: https://github.com/webim/webim-client-sdk-ios/blob/master/README.md Add the WebimMobileSDK to your Cartfile. ```ruby github "webim/webim-client-sdk-ios" ~> 4.0.0 ``` -------------------------------- ### Swift Package Manager Installation Source: https://github.com/webim/webim-client-sdk-ios/blob/master/README.md Steps to add the WebimClientLibrary to your app target using Swift Package Manager in Xcode. ```swift 1. Select File > Swift Packages > Add Package Dependency. Enter https://github.com/webim/webim-client-sdk-ios in the "Choose Package Repository" dialog. 2. In the next page, specify the version resolving rule as "Up to Next Major" with the latest webim-client-sdk-ios release. 3. After Xcode checking out the source and resolving the version, you can choose the "WebimClientLibrary" library and add it to your app target. ``` -------------------------------- ### startChat(departmentKey:firstQuestion:customFields:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Starts a chat with a specific department, sends a first message, and allows custom fields. This method requires server support and is mandatory when the VisitSessionState is in the departmentSelection state. ```swift startChat(departmentKey:firstQuestion:customFields:) ``` -------------------------------- ### CocoaPods Installation Source: https://github.com/webim/webim-client-sdk-ios/blob/master/README.md Add the WebimMobileSDK pod to your target in your Podfile. 'use_frameworks!' must be specified. ```ruby pod 'WebimMobileSDK' ``` -------------------------------- ### Message Equality Check Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Example demonstrating how to compare two Message objects for identical content using the isEqual(to:) method. ```swift if messageOne.isEqual(to: messageTwo) { /* … */ } ``` -------------------------------- ### sendKeyboardRequest(button:message:completionHandler:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Sends a keyboard request with a selected button and message. ```swift sendKeyboardRequest(button:message:completionHandler:) ``` -------------------------------- ### setVisitorTyping(draftMessage:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Notifies the server when the visitor is typing a message. The draftMessage parameter should contain the current content of the input field. Passing nil indicates the visitor stopped typing or deleted the message. Draft messages are sent to the service at most once per second. ```swift setVisitorTyping(draftMessage:) ``` -------------------------------- ### send(file:filename:mimeType:completionHandler:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Sends a file message. This method requires server support. If an active MessageTracker is present, its added(message:after:) method will be called. Returns a randomly generated message ID. ```swift send(file:filename:mimeType:completionHandler:) ``` -------------------------------- ### Image Thumbnail Size Calculation Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Calculates the appropriate dimensions for an image thumbnail based on a maximum size, adjusting width and height proportionally. ```swift let THUMB_SIZE = 300 var width = imageInfo.getWidth() var height = imageInfo.getHeight() if (height > width) { width = (THUMB_SIZE * width) / height height = THUMB_SIZE } else { height = (THUMB_SIZE * height) / width width = THUMB_SIZE } ``` -------------------------------- ### sendKeyboardRequest(buttonID:messageCurrentChatID:completionHandler:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Sends a keyboard request using a button ID and current chat ID. ```swift sendKeyboardRequest(buttonID:messageCurrentChatID:completionHandler:) ``` -------------------------------- ### send(message:isHintQuestion:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Sends a text message, indicating whether it's a hint selection or a user-typed message. This method requires server support. If an active MessageTracker is present, its added(message:after:) method will be called. Returns a randomly generated message ID. ```swift send(message:isHintQuestion:) ``` -------------------------------- ### send(message:data:completionHandler:) Source: https://github.com/webim/webim-client-sdk-ios/blob/master/Documentation/Index.md Sends a text message with optional custom parameters. This method requires server support. If an active MessageTracker is present, its added(message:after:) method will be called. Returns a randomly generated message ID. ```swift send(message:data:completionHandler:) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.