Get Started - iOS
This section will cover a step-by-step approach to bridge your Flutter project to PowerTalk iOS SDK. We will be using Xcode to configure native code in Flutter project.
Last updated
This section will cover a step-by-step approach to bridge your Flutter project to PowerTalk iOS SDK. We will be using Xcode to configure native code in Flutter project.
Last updated
TapTalk.io helps you to implement real-time chat with any type of your client app with speed and efficiency. Our iOS SDK provides you with various methods to initialize, configure, and build the chat from the client-side - no server-side implementation is required because our reliable infra management service is delivered with the SDK. This page presents a brief overview of the SDK’s structure and abilities, then lets you go through the preliminary steps of implementing the SDK in your own app. We will be using Xcode for the native side implementation.
1. Login to TapTalk.io Dashboard, then choose Development -> Apps
2. Click New App Button, input App Name and choose Platform, and then click Create New App Button.
3. A pop-up dialog will be shown with provided App Key ID & App Key Secret
Note: Please remember to save your App Key ID & your App Key Secret because it will only be shown once and will be used in TapTalk.io initialization
You can install the PowerTalk iOS SDK using CocoaPods like the following. If you are new to CocoaPods, you can see more information in Cocoapods guides. First, navigate to the ios folder of your Flutter project directory, and check if a file named Podfile exists. If there is no Podfile in the ios folder, we will create a new one using terminal. Open a terminal window and navigate to the ios directory of your Flutter project, then create a Podfile by running the following command in the terminal:
Then Podfile will be created in your project directory. Open the Podfile and add the following lines to the Podfile.
Since TapTalk.io use uses git-lfs
(Git Large Files Storage) you will need to install GIT LFS to clone/install TapTalk.io SDK through Cocoapods.
Note: Make sure to install git-lfs
before pod install, otherwise the pod install / pod update will return an error
Easiest way to install git-lfs is using brew:
Next, after the git-lfs
is installed, install the TapTalk.io SDK through CocoaPods.
After the pod is successfully installed, we will handle the implementation in the native side using Xcode. Open the xcworkspace file in your project's ios folder. (The default project name for iOS should be Runner, in this case, open Runner.xcworkspace).
If you previously created a new Podfile in the ios folder, open Debug.xcconfig file under the Flutter folder (you can also press Cmd + Shift + O to search by file name) and add the following:
Then open the Release.xcconfig file and add the following lines:
To make sure TapTalk.io has all permission to access the user's media, file, location, and contact, the application needs to ask for permission. Open the info.plist file under the Runner folder, and add the following key-value pairs.
Information Property Key | Information Property Value |
Privacy - Camera Usage Description | $(PRODUCT_NAME) needs to request access to your camera to send image messages and take profile picture. |
Privacy - Contacts Usage Description | $(PRODUCT_NAME) need your permission to access your contact, we will sync your contact to our server and automatically find your friend so it is easier for you to find your friends. |
Privacy - Photo Library Additions Usage Description | $(PRODUCT_NAME) needs to request access to your photo library to save photos. |
Privacy - Photo Library Usage Description | $(PRODUCT_NAME) needs to request access to your photo library to send image messages and select profile picture. |
Privacy - Location When In Use Usage Description | $(PRODUCT_NAME) needs to request access to your location to send location messages. |
Privacy - Microphone Usage Description | $(PRODUCT_NAME) needs to request access to your microphone to record audio to send voice messages. |
Note: You can change Information Property Value with your preferred message, the string value will be displayed when the application requests the permission.
Background modes is required to handle background process in TapTalk.io. It is used to run some processes in the background before the app is killed. For more information about the processes, check out the background process section. To enable background modes, go to Target -> Capabilities, then turn Background Modes toggle to ON, next select Background fetch and Remote notifications
After you turn on the Background Modes, Required background modes key will be added automatically in your Info.plist as shown below.
After adding the required dependency, we can begin the next step by writing custom platform-specific code using platform channels.
If you have finished this step from the Android side, you can skip to the next step.
In this example, we will add the following inside the MyHomePageState class:
Method Channel to connect to the native iOS host
openPowerTalkUI()
function to open the chat room list view
A button to call the openPowerTalkUI()
function
Please note the name parameter in the MethodChannel constructor that was used (io.taptalk.powertalk
), and the method name in the invokeMethod()
parameter (initPowerTalk
, authPowerTalk
& openChatRoomList
). We will use the same names later to configure Flutter engine in the native side.
Next, we will configure the native side of the iOS host implementation. Go back to previously opened Xcode project, and open AppDelegate.m file. We will do the following:
Add a MethodChannel Result variable to handle asynchronous call
setMethodCallHandler to handle calls from the MethodChannel that we previously created.
Add native functions to initialize & authenticate PowerTalk SDK and open the chat room list view
You can obtain POWERTALK_AUTH_TICKET by following the guide in Authentication page.
To allow the iOS SDK to respond to the connection and state changes in your iOS client app, you have to implement all of our application delegate methods in your UIApplicationDelegate methods in AppDelegate file. You can follow the instructions in Implement Application Delegate page.
Note: In the Event Delegate page, you can find detailed information on the usages of TapTalk iOS SDK's delegates and callbacks.
You can now try running the app. Pressing the sample button will invoke the openPowerTalkUI
method that we previously created, which will initialize & authenticate PowerTalk SDK, and open the chat room list view once the initialization is completed. You may also try a different implementation and separate the init, authenticate, and the open view methods. You can also add more calls to other native methods with the same approach using the same MethodChannel.
Note: You can check a more complete implementation guide in the PowerTalk iOS section.