SDK allows the iOS app to integrate with floatbot.ai for iPhone and iPad devices
• Bot_ID
• Token/Key
You can get Bot_ID and Token for your app from floatbot.ai dashboard
• SDWebImage
• AFNetworking
CocoaPods (recommended)
Floatbot is available through CocoaPods. To install it, simply add the following line to your Podfile:
use_frameworks!
pod 'floatbot_iOS_sdk'
FloatbotView.shared.setEncryptionKey(encryptionKeyStr: "YOUR_ENCRYPTION_KEY")
FloatbotView.shared.fview(withFrame: CGRect(x:0,y: 0,width:UIScreen.main.bounds.size.width,height: UIScreen.main.bounds.size.height - 300),withViewContainer: self, withbot_id:"5cc00545e6293668180a5d12")
FloatbotView.shared.showHeader(isVisible: false)
FloatbotView.shared.showSessions()
FloatbotView.shared.setToken(tokenStr: "YOUR_AUTH_TOKEN")
To send APNS token to floatbot server to receive push notification, add following method in your project's -[AppDelegate application:didFinishLaunchingWithOptions:] method
FloatbotView.shared.updateToken(pushTokenStr: "YOUR_PUSH_TOKEN")
- Go to the Mac OS finder application, and search for “Keychain Access”. Open it.
- Find your App’s push certificate in the Certificates section. It will start with the string "Apple Development iOS Push Services" (Apple Production iOS push services” in case of production certificate)
- Expand the row, and you will find the private key.
- Select both the private key and certificate and export it as .p12 file and necessarily set a password.
- Upload the saved .p12 file in the field below selecting development environment or production environment depending on whether you are using it for dev or production push services.
To generate APNS certificate refer this : https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html
Upload your development / production certificate in Settings page.
To enable floatbot to send push notifications to the application, add this implementation of - application:didRegisterForRemoteNotificationsWithDeviceToken: in your AppDelegate file that captures the device token and sends it to floatbot server
Add below snippet in Appdelegate.swift file
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
return true
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print("DEVICE TOKEN = \(deviceToken)")
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
print(userInfo)
}
For any queries, email us. Email : contact@floatbot.ai
Floatbot is available under the MIT license. See the LICENSE file for more info.