Bumble 1.0.12

Bumble 1.0.12

utkarsh维护。



Bumble 1.0.12

  • 作者
  • utkarsh

HippoChat iOS SDK

安装 HippoChat 以查看并与您的 iPhone 应用用户交流。HippoChat SDK 通过 CocoaPods 分发。以下进行了文档说明

先决条件

  1. Hippo SDK 支持 iOS 9.0 及以上版本
  2. Hippo App_Secret_Key/Reseller_token
  3. Xcode

如果您在集成过程中有任何疑问,请通过以下链接联系我们[email protected]

步骤 1:使用 CocoaPods 安装

HippoChat 通过 CocoaPods 提供。要将 HippoChat 添加到您的项目中,如以下示例将 SDK 添加到 Podfile 中。

pod 'Hippo'

更新您的 Podfile 后,请在项目中运行 pod install(终端命令),以自动下载和安装 SDK。

请注意:HippoChat SDK 支持针对 iOS 10.0 的应用程序。SDK 与所有上述 iOS 10.0 的版本兼容

升级 HippoChat SDK 吗?

在项目目录中运行 pod update Hippo(终端命令)。

注意:当与Call SDK一起使用Hippo时,Hippo不支持位码。要继续使用Hippo,请从应用目标设置中禁用位码。即:应用目标 > 构建设置 > 启用位码 > 否。

注意:使用Hippo需要以下权限:-> 隐私 - 摄像头使用描述,隐私 - 使用麦克风的描述,隐私 - 相册添加使用描述,隐私 - 相册使用描述。为了避免崩溃,请将这些权限添加到info.plist中。

步骤2:添加HippoChat凭证

在将SDK添加到您的项目后,在调用/尝试使用Hippo SDK的任何其他功能/方法之前,请添加HippoChat凭证。

HippoChat凭证可以通过APP-SECRET-KEY'RESELLER-TOKEN'和'REFERENCE-ID'添加。下面详细介绍了这两种方法。

选项A - 通过YOUR-APP-SECRET-KEY添加凭证

以下列出添加凭证的常用方法。

HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY)

如果您打算使用多个APP-SECRET-KEY的应用,您必须将您的应用添加到仪表板中,这将为您的应用生成一个APP-TYPE,您将在设置凭证时使用它。使用同一APP-SECRET-KEY生成的不同应用将具有不同的APP-TYPE。

HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY, appType: YOUR-APP-TYPE)

注意:我们强烈建议您只添加一次凭证,并在您的AppDelegate的application:didFinishLaunchingWithOptions:或登录到您的应用程序时添加。不要忘记在以下代码片段中将YOUR-APP-SECRET-KEY替换为实际的app密钥。

func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
...
HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY)
...
}

注意:如果您想将应用程序名称设置为自定义推送通知,请使用以下方法添加您的Hippo凭证。

HippoConfig.shared.setAppName(withAppName: YOUR-APPNAME)

选项B - 通过'YOUR-RESELLER-TOKEN', 'YOUR-REFERENCE-ID'和'YOUR-APP-TYPE'添加凭证

在调用/尝试使用Hippo SDK的任何其他功能/方法之前,通过您的reseller_tokenrefernce_id键添加凭证。下面有详细说明。

HippoConfig.shared.setCredential(withToken: YOUR-RESELLER-TOKEN,
referenceId: YOUR-REFERENCE-ID,
appType: YOUR-APP-TYPE)

注意:我们强烈建议您只添加一次凭证,并在您的AppDelegate的application:didFinishLaunchingWithOptions:中添加。不要忘记在以下代码片段中将YOUR-RESELLER-TOKENYOUR-REFERENCE-IDYOUR-APP-TYPE替换为实际的reseller_token、reference_id和app_type。

func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
...
HippoConfig.shared.setCredential(withToken: YOUR-RESELLER-TOKEN,
referenceId: YOUR-REFERENCE-ID,
appType: YOUR-APP-TYPE)
...
}

步骤 3:更新用户信息

通过在您的服务器上更新/编辑用户资料时传递用户数据来更新启用了识别或登录的用户信息,如下所示

//Get the user object for the current installation (for customers)
let HippoUserDetail = HippoUserDetail(fullName: "<Full_name_string>",
email: "<Email_string>",
phoneNumber: "<phone_number_string>",
userUniqueKey: "<your_unique_identifier_for_user>",
addressAttribute: <initialize_HippoAttributes>,
customAttributes: <set_custom_attributes>,
selectedlanguage: <selected_language>
)

//Call updateUserDetails so that
//the user information is synced with Hippo servers 
HippoConfig.shared.updateUserDetail(userDetail: HippoUserDetail)

//For initialization of Hippo Manager
  HippoConfig.shared.initManager(authToken: "<User_auth_Token>", 
  app_type: "<App_Type>", 
  selectedLanguage: <selected_language>)

注意:如果您此处没有唯一的用户标识符来使用,或者如果您有一个userId和一个邮箱,您可以在注册对象中使用电子邮件/电话号码作为唯一键。

步骤 4:在您的应用程序中显示对话

针对特定UI事件(例如菜单选择或按钮点击事件),调用presentChatsViewController()方法来启动对话流。如果应用程序配置了多个频道,用户将看到频道列表。当没有消息时,频道列表的排序顺序与仪表板上的指定顺序相同。

// Launching Conversation List in your app screen
HippoConfig.shared.presentChatsViewController()

步骤 5:处理推送通知

使 Hippo 配置推送通知的步骤

  1. 将设备注册令牌发送到 Hippo
  2. 自定义通知外观并将通知数据传递给 Hippo
  3. 处理推送通知点击事件

1:发送设备注册令牌

使用 SDK,HippoChat 可以向用户发送推送通知。为了启用此支持,当您的应用程序代理接收到 application:didRegisterForRemoteNotificationsWithDeviceToken: 方法时,请添加对以下 registerDeviceToken(deviceToken: Data) 方法的调用:

func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
HippoConfig.shared.registerDeviceToken(deviceToken: deviceToken)
}

2: 自定义通知外观并将通知数据传递给 Hippo

收到远程通知后,将远程通知的 userInfo 传递给 isHippoNotification(withUserInfo: pushInfo)showNotification(userInfo: pushInfo) 方法,如以下所述以验证 Hippo 通知:

func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
let pushInfo = (userInfo as? [String : Any]) ?? [:]
if HippoConfig.shared.isHippoNotification(withUserInfo: pushInfo) {

if HippoConfig.shared.showNotification(userInfo: pushInfo) {
...
//setup banner or any UI you want to show inside your app
//and call `HippoConfig.shared.handleRemoteNotification(userInfo: pushInfo)`
//after tapping on that banner
...
}
return
} 
}

步骤 6:登出时清除用户数据

通过调用 clearHippoUserData() 函数在登出时或在根据用户在应用程序中的操作认为适当的情况下清除用户数据。

HippoConfig.shared.clearHippoUserData()

高级功能

其他信息代理

在类中继承 "HippoDelegate",然后将其设置为 HippoConfig.shared.setHippoDelegate(delegate: <-Your class->),这样它就会通知类任何可以使用的任何信息或任何消息。此代理还用于获取视图调用和音频调用的视图。

HippoConfig.shared.setHippoDelegate(delegate: <HippoDelegate>)

使用 channelID 打开特定聊天

在响应特定的 UI 事件(如菜单选择或按钮点击事件)时,通过传递 Channel-ID 调用 openChatWith(channelId: Int, completion: (_ success: Bool, _ error: Error?) -> Void) 方法以启动指定的频道,如下所示:

// Launching Conversation List from click of a button in your app's screen
HippoConfig.shared.openChatWith(channelId: CHANNEL_ID, completion: { (success, error) in
// handle success or error
})

在特定交易中打开独特聊天

如果您希望通过特定的交易打开一个独特的频道,例如如果您需要与您特定订单对应的聊天,您可以通过调用openChatScreen(withTransactionId transactionId: String, tags: [String]? = nil, channelName: String, message: String = "", userUniqueKey: String? = nil, completion: @escaping (_ success: Bool, _ error: Error?) -> Void)方法。

// Launching Conversation List from click of a button in your iOS app
/**
- parameter withTransactionId: Unique ID to recognize your chat, ex. your OrderID
- parameter tags: Additional Information which will be user to distinguis chats in Dashboard
- parameter channelName: If you want to specify a name for the chat, or you can leave it empty 
- parameter message: Optional parameter, if you want to start a chat with a first message already added
HippoConfig.shared.openChatScreen(withTransactionId: "<transation_id>",
tags: ["<tag_1>, <tag_2>"],
channelName: "<channel_name>", message: "First message after opening the chat")

打开点对点聊天

使用HippoConfig.shared.showPeerChatWith(data: PeerToPeerChat, completion: @escaping (_ success: Bool, _ error: Error?) -> Void)来打开与Peer的聊天屏幕。

/**
- parameter uniqueChatId: Unique ID you will use to recognize seprate chats between same peers. Could be set to `nil` if there is no need to create seprate chat between same peers.
- parameter myUniqueId: ID which your systems uses to recognize you uniquely.
- parameter idsOfPeers: Unique IDs of peers with whom you want to start chat.
- parameter channelName: Name you want to give your chat, If you want peers name to show pass empty string.
*/
let peerChatInfo = PeerToPeerChat(uniqueChatId: "YOUR-UNIQUE-CHAT-ID", myUniqueId: "YOUR-UNIQUE-ID", idsOfPeers: ["PEER-UNIQUE-ID"], channelName: "CHANNEL-NAME")

HippoConfig.shared.showPeerChatWith(data: peerChatInfo, completion: { (success, error) in
//handle success or error
})

在开发和生产环境之间切换

使用HippoConfig.shared.switchEnvironment(_ envType: HippoEnvironment)来在开发和生产环境之间切换

HippoConfig.shared.switchEnvironment(.dev)

或者

HippoConfig.shared.switchEnvironment(.live)

live 是默认选择。

更改 Hippo 聊天屏幕的颜色,以匹配您的应用的视觉风格

使用HippoConfig.shared.setCustomisedHippoTheme(theme: HippoTheme)方法轻松地将您的应用外观复制到Hippo屏幕中,以下是一个示例代码片段:

我们强烈建议只在您的AppDelegate的application:didFinishLaunchingWithOptions中添加一次凭证。

func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
...
let hippotheme = HippoTheme.defaultTheme()
hippotheme.backgroundColor = .black
hippotheme.headerBackgroundColor = .black
hippotheme.headerTextColor = .black
hippotheme.headerText = "support"
hippotheme.promotionsAnnouncementsHeaderText = "Announcements"

HippoConfig.shared.setCustomisedHippoTheme(theme: hippotheme)
...
}

在 Hippo Theme 中传递字体

使用HippoTheme.defaultTheme(fontRegular: "", fontBold: "")在 Hippo Theme 中传递您的应用程序字体

/**
- parameter fontRegular: Pass app regular font here
fontBold: Pass app Bold/Semi-Bold font here
*/

多语言支持

使用 HippoConfig.shared.setLanguage(_ code: String) 从应用程序传递选择的语言代码以使用特定语言

/**
- parameter code: Pass language code here. For example: "en" for English or "es" For Spanish
*/

初始化机器人(管理者不可用)

使用 HippoConfig.shared.setNewConversationBotGroupId(botGroupId:) 传递您的 botgroupid

公告部分(管理者不可用)

使用 HippoConfig.shared.presentPromotionalPushController() 从您的应用程序打开公告部分

Hippo SDK 设置视频通话

要启用 Hippo SDK 中的视频通话,请从 hippo 控制板设置 > 插件 > 视频通话启用它

注意:请参阅“其他信息”段落,点击此处,因为您必须从应用程序视图发送视频通话/音频通话。

1: 安装 Call SDK

安装 Call SubPod 以支持视频和音频通话。

pod 'Hippo/Call'

更新您的 Podfile 后,请在项目中运行 pod install(终端命令),以自动下载和安装 SDK。

2: 首先在您的应用代理中注册 VOIP 通知

您可以参考以下链接。如果已完成,请继续下一步操作 https://medium.com/ios-expert-series-or-interview-series/voip-push-notifications-using-ios-pushkit-5bc4a8f4d587

3: 发送 Voip 设备注册令牌

HippoChat 使用 SDK 能够向您的用户发送推送通知。为了启用此支持,当您的应用代理接收到 _ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType 方法时,请在以下示例中包含对 registerVoipDeviceToken(deviceToken: Data) 的调用

func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let token = pushCredentials.token
HippoConfig.shared.registerVoipDeviceToken(deviceData: token)
}

4: 将 Voip 通知数据传递给 Hippo SDK

接收 Voip 通知后,将 remoteNotification userInfo 传递到 isHippoNotification(withUserInfo: pushInfo)showNotification(userInfo: pushInfo) 方法以验证 Hippo 通知,如下所示

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
guard type == PKPushType.voIP else {
return
}
if HippoConfig.shared.isHippoNotification(withUserInfo: pushInfo) {
HippoConfig.shared.handleVoipNotification(payloadDict: payload.dictionaryPayload)
} else {
//Its your voip push to handle
}
}

5: 启动点对点视频聊天

使用 HippoConfig.shared.startVideoCall(data: PeerToPeerChat, completion: @escaping (_ success: Bool, _ error: Error?) -> Void) 打开聊天界面与对方。

/**
- parameter uniqueChatId: Unique ID you will use to recognize seprate chats between same peers. Could be set to `nil` if there is no need to create seprate chat between same peers.
- parameter myUniqueId: ID which your systems uses to recognize you uniquely.
- parameter idsOfPeers: Unique IDs of peers with whom you want to start chat.
- parameter channelName: Name you want to give your chat, If you want peers name to show pass empty string.
- parameter peerName: Other peer name to show on screen.
*/
let peerChatInfo = PeerToPeerChat(uniqueChatId: "YOUR-UNIQUE-CHAT-ID", myUniqueId: "YOUR-UNIQUE-ID", idsOfPeers: ["PEER-UNIQUE-ID"], channelName: "CHANNEL-NAME", peerName: "Peer name")

HippoConfig.shared.startVideoCall(data: peerChatInfo, completion: { (success, error) in
//handle success or error
})