REVE Chat’s Flutter iOS SDK can be seamlessly integrated with your mobile apps and enable your team deliver in-app messaging to your app users for better engagement and customer support.
This tutorial shows you how to add Flutter iOS and get started in a few minutes.
Necessary or minimum requirements:
CocoaPods (recommended)
# For latest release in cocoapods
uncomment the line use_frameworks!
pod 'ReveChatSDK'
To integrate Flutter iOS SDK with your iOS mobile app, please follow the below mentioned steps:
The iOS SDK uses the camera and photo library in iOS.
If your app does not already request permissions for these features, you should update your info.plist file with a usage description for NSPhotoLibraryUsageDescription and NSCameraUsageDescription.
*/* You can do this by adding the following lines in your plist source code */*
<key>NSPhotoLibraryUsageDescription</key>
<string><description to use photo library></string>
<key>NSCameraUsageDescription</key>
<string><description to use camera></string>
<key>NSAppTransportSecurity</key> <dict>
<key>NSAllowsArbitraryLoads</key>
<true/></dict>
<key>NSMicrophoneUsageDescription</key>
<string><Add your description here></string>
let flutterVC = FlutterViewController()
let navVC = UINavigationController(rootViewController: flutterVC)
self.window?.rootViewController = navVC
navVC.navigationBar.isHidden = true
let batteryChannel = FlutterMethodChannel(name: "com.revechat.sdk/sdkchannel",
binaryMessenger: flutterVC.binaryMessenger)
batteryChannel.setMethodCallHandler({
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
let reveChatManager = ReveChatManager()
reveChatManager.setupAccount(with: "account_number") // put your account_number here
switch call.method {
case "StartREVEChat":
print("success")
guard let args = call.arguments as? [String:String] else {
print("failed fetching")
return
}
let name = args["name"]!
let email = args["email"]!
let phone = args["phone"]!
reveChatManager.initiateReveChat(with: name,
visitorEmail: email,
visitorMobile: phone,
onNavigationViewController: flutterVC.navigationController)
break
default:
break
}
})
Future<void> _startActivity() async {
try {
const platform = MethodChannel('com.revechat.sdk/sdkchannel');
final String result = await platform.invokeMethod('StartREVEChat',{
'email':'[email protected]', // put your email here
'name':'netzaintest', //put your name here
'phone':'01409404444', //put your mobile number her
});
debugPrint('Result: $result ');
} on PlatformException catch (e) {
debugPrint("Error: '${e.message}'.");
}
}
floatingActionButton: FloatingActionButton(
onPressed: _startActivity,
tooltip: 'Increment',
child: const Icon(Icons.add),
)
* Objective c
#import < ReveChatSDK/ReveChatSDK.h>
* swift
import ReveChatSDK
* Objective c
[[ReveChatManager sharedManager]
setupAccountWith:<your account id>];
* swift
/* declare object for reve chat manager class*/
let reveChatManager = ReveChatManager()
reveChatManager.setupAccount(with: <your account id as string> )
* Obj c
[[ReveChatManager sharedManager]
initiateReveChatWith:<visitor name>
visitorEmail:<visitor email>
visitorMobile:<visitor mobile>
onNavigationViewController:<your navigation
controller>];
* Swift
/* initiate the class with name, email , mobile and parent controller of the sdk as parameters*/
reveChatManager.initiateReveChat(with: <visitor name>,
visitorEmail: <visitor email>,
visitorMobile: <visitor mobile>,
onNavigationViewController: <UINavigationController on which you want it to load>)
*To initiate video call.The audio parameter should be false
You can enable the notification when the app is in background mode. Use the below code:
var backgroundUpdateTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier(rawValue: 0)
Method name : “sceneDidBecomeActive” or “applicationDidBecomeActive”
self.endBackgroundUpdateTask()
Method name “sceneWillResignActive” or “applicationWillResignActive”
self.backgroundUpdateTask = UIApplication.shared.beginBackgroundTask(expirationHandler: {
self.endBackgroundUpdateTask()
})
func endBackgroundUpdateTask() {
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
}
* Objective c
/* for title while chatting */
[ReveChatManager sharedManager].title = @"me talking";
/* for theme color while chatting */
[ReveChatManager sharedManager].themeColor = [UIColor blueColor];
/* for background color */
[ReveChatManager sharedManager].backgroundColor = [UIColor yellowColor];
/* for navigation bar color */
[ReveChatManager sharedManager].navBarColor = [UIColor orangeColor];
/* for tint color of navigation bar while chatting */
[ReveChatManager sharedManager].headerTintColor = [UIColor whiteColor];
/* for title color while chatting */
[ReveChatManager sharedManager].headerTextColor = [UIColor whiteColor];
/* for incoming chat bubble color */
[ReveChatManager sharedManager].incomingBubbleColor = [UIColor blueColor];
/* for outgoing chat bubble color */
[ReveChatManager sharedManager].outgoingBubbleColor = [UIColor blueColor];
* Swift
/* for title while chatting */
reveChatManager.setChatTitle("Lets chat")
/* for theme color while chatting*/
reveChatManager.themeColor = UIColor.blue
/* for background color*/
reveChatManager.backgroundColor = UIColor.yellow
/* for navigation bar color*/
reveChatManager.navBarColor = UIColor.gray
/* for tint color of header */
reveChatManager.headerTintColor = UIColor.red
/* for title color while chatting*/
reveChatManager.headerTextColor = UIColor.black
/* for incoming chat bubble color*/
reveChatManager.incomingBubbleColor = UIColor.blue
/* for outgoing chat bubble color*/
reveChatManager.outgoingBubbleColor = UIColor.yellow