Pozzito 1.4.1

Pozzito 1.4.1

许可证 自定义
发布最新版本2017年10月

Pozzito 维护。



Pozzito 1.4.1

  • Sedam IT

安装

Pozzito支持iOS 9及以上版本。

手动安装

  1. 下载Pozzito并解压缩。

  2. 转到您的Xcode项目的“一般”设置。将Pozzito.framework拖放到“嵌入式二进制文件”部分。确保选中“如果需要则复制项”,然后单击完成。

  3. 在应用目标中创建一个新的“运行脚本阶段”,并将下面的代码片段粘贴到脚本文本字段中

     bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pozzito.framework/strip-frameworks.sh"
    

此步骤是解决将通用二进制文件存档时出现的App Store提交错误的必要步骤。

##设置和配置

PozzitoManager

首先,为了使用Pozzito,您需要拥有API密钥和app id,您可以在我们的网站上注册时获取这些信息

安装Pozzito后,您需要将它导入您想要使用的文件中,并使用apiKey和appId实例化PozzitoManager。

PozzitoManager(apiKey: "api key string", appId: "app id string", completion: { (err) in
    //error handling
})

在实例化后,您可以使用CoreService,ConversationService和ChatService。

CoreService用于处理用户相关请求,ConversationService用于处理聊天相关请求,ChatService用于处理套接字,订阅等。

CoreService

######可用方法

/// Creates new end user object and authenticates current user
/// If there are no user parameters, an anonymous user is created
///
/// - Parameter userParameters: Optional dictionary with user parameters,
///                             current options - userName, firstName, lastName
public func createEndUser(userParameters: RequestDictionary? = nil,
completion: @escaping (UserModel?, ServiceError?) -> Void)

/// Updates end user data with input parameters
///
/// - Parameter userParameters: Dictionary with user parameters,
///                             current options - userName, firstName, lastName
public func updateUser(userParameters: RequestDictionary,
completion: @escaping (UserModel?, ServiceError?) -> Void)

######示例

当您想要创建一个用户时,请使用CoreService的createEndUser方法,带或不带用户参数。

如果您不提供参数,Pozzito将创建一个匿名用户。

当前可能的参数是userName,firstName和lastName。

当创建用户对象时,用户已保存,因此您无需做出任何操作。

CoreService.shared.createEndUser(completion: { (user, error) in
    //user || error handling, proceeding to conversations etc
})

ConversationService

######可用方法

/// Fetches all conversations from the server
///
/// - Parameters:
///   - parameters: Dictionary with parameters used for filtering response, optional
public func getAllConversations(parameters: RequestDictionary? = nil,
completion: @escaping ([ConversationModel]?, ServiceError?) -> Void)

/// Calls api service create method with conversation resource
public func createConversation(parameters: RequestDictionary? = nil,
completion: @escaping (ConversationModel?, ServiceError?) -> Void)

/// Sends chat score to the server
///
/// - Parameter scoreId: Selected score id
public func sendConversationScore(conversationId: String, scoreId: String,
completion: @escaping (ConversationModel?, ServiceError?) -> Void)

/// Fetches possible satisfaction scores from the server
public func getSatisfactionScores(completion: @escaping ([SatisfactionScoreModel]?, ServiceError?)

/// Updates conversation status on the server to seen
public func setConversationSeen(conversationId: String,
completion: @escaping (ConversationModel?, ServiceError?) -> Void)

/// Fetches conversation from the server with the given id
///
/// - Parameter id: conversation id
public func getConversation(conversationId: String,
completion: @escaping (ConversationModel?, ServiceError?) -> Void)

######示例

当您想要开始聊天时,请使用带有包含聊天描述字典的ConversationService的createConversation方法,作为参数,键为“description”。

ConversationService.shared.createConversation(parameters: conversationParameters, completion: { (conversation, error) in
    //conversation || error handling, proceeding to chat
})

当您想要获取认证用户的所有聊天时,请使用ConversationService的getAllConversations方法。

ConversationService.shared.getAllConversations(completion: { (conversations, error) in
    //conversations || error handling, displaying conversations etc
})

ChatService

######可用方法

/// Configures chat service, used to set initial parameters
///
/// - Parameters:
///   - tenantId: Tenant organization id
///   - userId: Current user id
///   - chatId: Conversation id
///   - delegate: Chat event protocol delegate, class in which you display chat UI
public func configureChat(tenantId: String?, userId: String?, chatId: String?, delegate: ChatEventDelegate?)

/// Chat client attempts to send message
///
/// - Parameter message: Message text
public func sendMessage(message: String)

/// Attempts to connects chat client
///
/// - Parameters:
///   - firstMessage:  optional first message parameter
public func connectChat(firstMessage: String? = nil)

/// Attempts to disconnect chat client
public func disconnectChat()

要连接到套接字并使用聊天功能,请使用ChatService和ChatEventDelegate协议以通知您的控制器聊天事件的重复发生。

首先必须使用configureChat方法将其正确配置,然后才能尝试使用connectChat方法连接。

要发送消息,请使用sendMessage方法,要断开聊天,请使用disconnectChat方法。

#####ChatEventDelegate

用于通知用于显示聊天功能的类的协议。

######可用方法

func chatErrorReceived(errorDescription: String)
func chatMessageReceived(message: [String : AnyObject])
func chatEnded()
func connected()
func connecting()
func disconnected()