Install HippoChat to see and talk to users of your iPhone app. The HippoChat SDK is distributed via CocoaPods. This method is documented below:
- Hippo SDK supports iOS 11.0 and above
- Hippo App_Secret_Key/Reseller_token
- Xcode
If you have any queries during the integration, please reach out to us at support@fuguchat.com
HippoChat is available through CocoaPods. To add HippoChat to your project, add the SDK to your Podfile as shown below.
-
If you want to use hippo without calling or if you want to use jitsi calling add the below line to your prject's pod file
pod 'Hippo', :git => 'https://github.com/Jungle-Works/Hippo-iOS-SDK', :branch => 'master'
-
If you want to use hippo with Video sdk calling add the below line to your prject's pod file
pod 'Hippo', :git => 'https://github.com/Jungle-Works/Hippo-iOS-SDK', :branch => 'VideoSDKRelease'
Once you have updated your Podfile run pod install
(terminal command) to automatically download and install the SDK in your project.
Please note: HippoChat SDK supports apps targeting iOS 10.0+. The SDK itself is compatible with all the above iOS 10.0
Run pod update Hippo
(terminal command) in your project directory.
Note: Hippo dose not support bitcode when using it with Call SDK, to continue with hippo disable bitcode from app target setting .i.e., app_target > build setting > Enable Bitcode > No
Note: Permission required for using Hippo:->> Privacy - Camera Usage Description, Privacy - Microphone Usage Description, Privacy - Photo Library Additions Usage Description, Privacy - Photo Library Usage Description. Add these permissions in info.plist for avoiding crashes.
Note: Add capabiliteis "Background modes" in Hippo:->> signing and capabilities tab and enable remote notification, voice over IP, audio/picture in picture
After adding SDK to your project, add HippoChat Credentials before invoking/attempting to use any other feature/method of Hippo SDK.
The HippoChat credential is added either via APP-SECRET-KEY
or 'RESELLER-TOKEN' and 'REFERENCE-ID'
. Both methods are documented below:
Commonly used way to add credential listed below.
HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY)
If you are going to use multiple apps from same APP-SECRET-KEY you must add your apps in Dashboard which will generate an APP-TYPE, which you will use while setting your credentials. APP-TYPE will be different for different apps generated with same APP-SECRET-KEY.
HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY, appType: YOUR-APP-TYPE)
Note: We highly recommend to add credential only once and from your AppDelegate's application:didFinishLaunchingWithOptions: or when you log in into your app.
Don't forget to replace the YOUR-APP-SECRET-KEY
in the following code snippet with the actual app secret key.
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
...
HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY)
...
}
Note: If you want to set your app name in custom push notifications than use the following method where you add your Hippo Credentials
HippoConfig.shared.setAppName(withAppName: YOUR-APPNAME)
Add credential via your reseller_token
and refernce_id
key before invoking/ attempting to use any other features/methods of Hippo SDK. As documented below:
HippoConfig.shared.setCredential(withToken: YOUR-RESELLER-TOKEN,
referenceId: YOUR-REFERENCE-ID,
appType: YOUR-APP-TYPE)
Note: We highly recommend to add credential only once and from your AppDelegate's application:didFinishLaunchingWithOptions:
Don't forget to replace YOUR-RESELLER-TOKEN
, YOUR-REFERENCE-ID
and YOUR-APP-TYPE
in the following code snippet with the actual reseller_token, reference_id and 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)
...
}
Update Identified or logged in user information by passing user data whenever you update/edit user profile on your server like this:
//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)
HippoConfig.shared.setCredential(withAppSecretKey: YOUR-APP-SECRET-KEY, appType: YOUR-APP-TYPE)
//For initialization of Hippo Manager
HippoConfig.shared.initManager(authToken: "<User_auth_Token>",
app_type: "<App_Type>",
selectedLanguage: <selected_language>)
Note : If you don't have a unique user identifier to use here, or if you have a userId and an email you can use Email/Phone number on the Registration object as unique key.
# Step 4: Showing conversations inside your application
In response to a specific UI events like a menu selection or button tap event, call the `presentChatsViewController()` method to launch the Conversation Flow. If the app has multiple channels configured, the user will see the channel list. Channel list is ordered as specified in the Dashboard when there are no messages.
```sh
// Launching Conversation List in your app screen
HippoConfig.shared.presentChatsViewController()
- Sending the device registration token to Hippo
- Customizing Notification appearance and passing notification data to Hippo
- Handle push notification click
HippoChat using the SDK is capable of sending push notifications to your users. To enable this support, when your app delegate receives the application:didRegisterForRemoteNotificationsWithDeviceToken: method, include a call to registerDeviceToken(deviceToken: Data)
as below:
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
HippoConfig.shared.registerDeviceToken(deviceToken: deviceToken)
}
After receiving remote notification, pass the remoteNotification userInfo into isHippoNotification(withUserInfo: pushInfo)
and showNotification(userInfo: pushInfo)
method to validate Hippo notification as mentioned below:
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
}
}
Clear user data at logout or when deemed appropriate based on user action in the app by invoking the clearHippoUserData()
function:
HippoConfig.shared.clearHippoUserData()
Inherit "HippoDelegate" to a class and then set it to HippoConfig.shared.setHippoDelegate(delegate: <-Your class->), This will notifiy that class on any information or any message that you can use. This delegate is also used for getting view for view call and audio call
HippoConfig.shared.setHippoDelegate(delegate: <HippoDelegate>)
In response to a specific UI events like a menu selection or button tap event, call the openChatWith(channelId: Int, completion: (_ success: Bool, _ error: Error?) -> Void)
method to launch the specified channel by passing Channel-ID
as mentioned below:
// 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
})
If you want to open a unique channel by your specific transaction for example if you want a chat corresponding to your particular Order, you can call openChatScreen(withTransactionId transactionId: String, tags: [String]? = nil, channelName: String, message: String = "", userUniqueKey: String? = nil, completion: @escaping (_ success: Bool, _ error: Error?) -> Void)
method.
// 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")
Use HippoConfig.shared.showPeerChatWith(data: PeerToPeerChat, completion: @escaping (_ success: Bool, _ error: Error?) -> Void)
to open chat screen with 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
})
Use HippoConfig.shared.switchEnvironment(_ envType: HippoEnvironment)
to switch between development and Live enviroments
HippoConfig.shared.switchEnvironment(.dev)
OR
HippoConfig.shared.switchEnvironment(.live)
live
is selected by Default.
Use HippoConfig.shared.setCustomisedHippoTheme(theme: HippoTheme)
method to easily replicate your application’s look and feel in Hippo Screens, reference code snippet is as follows :
We highly recommend to add credential only once and from your AppDelegate’s 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)
...
}
Use HippoTheme.defaultTheme(fontRegular: "", fontBold: "")
to paas your app fonts in Hippo Theme
/**
- parameter fontRegular: Pass app regular font here
fontBold: Pass app Bold/Semi-Bold font here
*/
Use HippoConfig.shared.setLanguage(_ code : String)
to paas selected language code from your application for using language in particular language
/**
- parameter code: Pass language code here. For example: "en" for English or "es" For Spanish
*/
Use HippoConfig.shared.setNewConversationBotGroupId(botGroupId:)
to paas your botgroupid
Use HippoConfig.shared.presentPromotionalPushController()
for opening Annoucements section from your application
To enable audio/video call in Hippo SDK, enable it from hippo dashboard setting > add on > audio/video call
Note: Please go through Other Infomation delegate paragraph, Click Here , as you have to send video call/ Audio Call in app View.
Install Call SubPod for video and audio call.
-
If you want to use hippo without calling or if you want to use jitsi calling add the below line to your prject's pod file
pod 'Hippo/Call', :git => 'https://github.com/Jungle-Works/Hippo-iOS-SDK', :branch => 'master'
-
If you want to use hippo with Video sdk calling add the below line to your prject's pod file
pod 'Hippo/Call', :git => 'https://github.com/Jungle-Works/Hippo-iOS-SDK', :branch => 'VideoSDKRelease'
Once you have updated your Podfile run pod install
(terminal command) to automatically download and install the SDK in your project.
You can take reference from below mentioned link. If already done continue to next step https://medium.com/ios-expert-series-or-interview-series/voip-push-notifications-using-ios-pushkit-5bc4a8f4d587
HippoChat using the SDK is capable of sending push notifications to your users. To enable this support, when your app delegate receives the _ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType method, include a call to registerVoipDeviceToken(deviceToken: Data)
as below:
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let token = pushCredentials.token
HippoConfig.shared.registerVoipDeviceToken(deviceData: token)
}
After receiving Voip notification, pass the remoteNotification userInfo into isHippoNotification(withUserInfo: pushInfo)
and showNotification(userInfo: pushInfo)
method to validate Hippo notification as mentioned below:
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
}
}
Use HippoConfig.shared.startVideoCall(data: PeerToPeerChat, completion: @escaping (_ success: Bool, _ error: Error?) -> Void)
to open chat screen with 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.
- 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, callType: .(audio/video), completion: { (success, error) in
//handle success or error
})
- After installing hippo call client pod selecte pods in your project's root directory in xcode, below your project name
- In targets select HippoCallClient(Blue one) and in build phases select copy bundle resources click + icon and add VideoSDK.storyboard and ButtonControlsView.xib
To enable advance stats to update when user click on notification and time user spent in the app you have to add below mentioned code to your project's app delegate file.
-- In appDelegate file found didFinishLaunchWithOptions add the code: if let lauchOptionInfo = launchOptions, let remoteNotification = lauchOptionInfo[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { userInfo = remoteNotification
if (remoteNotification["is_announcement_push"] as? Int != nil && remoteNotification["is_announcement_push"] as? Int == 1) || (remoteNotification["channel_type"] as? Int != nil && remoteNotification["channel_type"] as? Int == 6) {
openendFromPush = true
DispatchQueue.main.asyncAfter(deadline: .now() + 1.7) {
ChatSDK.shared.handelPush(userInfo: remoteNotification)
}
}
}
-- add this function in your appDelegate file:� func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if openendFromPush || (UIApplication.shared.applicationState != .background && UIApplication.shared.applicationState != .active){
openendFromPush = false
return
}
if let userInfo = userInfo as? [String : Any]{
HippoConfig.shared.managePromotionOrP2pCount(userInfo)
HippoConfig.shared.callMissedFromUser(userInfo: userInfo)
completionHandler(UIBackgroundFetchResult.newData)
}else{
completionHandler(UIBackgroundFetchResult.failed)
}
}
-- In didReceiveResponse add: if HippoConfig.shared.isHippoNotification(withUserInfo: userInfo) { HippoConfig.shared.handleRemoteNotification(userInfo: userInfo) }
-- In app delegate add this function to update session time to backend: func applicationWillResignActive(_ application: UIApplication) { HippoConfig.shared.hitStatsApi(userInfo: nil, sendSessionTym: true) }
-- To show promotional pop up in your app on any screen and receive data on button click add below mentioned code: HippoConfig.shared.presentPromotionalPopUp(on: Your_View_Controller) { data in print("Button one call back received with (data)") } onButtonTwoClick: { data in print("Button two call back received with (data)") }
To receive call back on bot button tap with the data add the following code - HippoConfig.shared.newChatCallback = { [weak self] totalChats in print("CallBackReceived", totalChats) return(maxChats, closeHippo) }
Here you have to pass the maxChats you want to enable the user can create, and pass a boolean value to close hippo if the max limit passed will reach, you will receive a callback everytime when user creates a new chat.
-
Create notification content extension as described here (https://riptutorial.com/ios/example/32292/creating-a-simple-unnotificationcontentextension)
-
Go to the info plist file of the extension created and change the value for key - "UNNotificationExtensionCategory" to "ColorNotification"
-
In the info plist file of the extension add this key - "UNNotificationExtensionDefaultContentHidden" and set it's value "Yes\No", according to your UI preferences
-
Go to the view controller associated with the extension and in the function "func didReceive(_ notification: UNNotification)" add this code -
" if let notifData = notification.request.content.userInfo as? [String: Any], let customAttr = notifData["custom_attributes"] as? [String: Any], let notiColor = customAttr["notification_color"] as? String, let textColor = customAttr["font_color"] as? String, let text = customAttr["description"] as? String{ self.view.backgroundColor = UIColor(notiColor) self.label?.textColor = UIColor(textColor) self.label?.text = notification.request.content.title + "\n" + text } "
😍 🥳 🤩 Notifications are good to go now use it 😍 🥳 🤩
-
Add app group to your app
-
Add new target to your app named - "Broadcast upload extension"
-
Assign same app group to the newly added target
-
Download the files from this url - https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/ios/swift-screensharing/JitsiSDKScreenSharingTest/Broadcast%20Extension/Atomic.swift https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/ios/swift-screensharing/JitsiSDKScreenSharingTest/Broadcast%20Extension/DarwinNotificationCenter.swift https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/ios/swift-screensharing/JitsiSDKScreenSharingTest/Broadcast%20Extension/SampleHandler.swift https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/ios/swift-screensharing/JitsiSDKScreenSharingTest/Broadcast%20Extension/SampleUploader.swift https://github.com/jitsi/jitsi-meet-sdk-samples/blob/master/ios/swift-screensharing/JitsiSDKScreenSharingTest/Broadcast%20Extension/SocketConnection.swift
-
Drag the downlaoded files in the broadcast extension target
-
Open sample handler and replace the app group with your app's app group
-
Open JitsiConferenceCallView.swift and add this line below line number 66 - "ptionsBuilder.setFeatureFlag("ios.screensharing.enabled", withValue: true)"
😍 🥳 🤩 Screen sharing is good to go now use it 😍 🥳 🤩