<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sanufaris on Medium]]></title>
        <description><![CDATA[Stories by Sanufaris on Medium]]></description>
        <link>https://medium.com/@sanufaris5?source=rss-29aa33e3b062------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*TU-YtcIiIfPPTVgx</url>
            <title>Stories by Sanufaris on Medium</title>
            <link>https://medium.com/@sanufaris5?source=rss-29aa33e3b062------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:36:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanufaris5/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Implementation of One-to-One Video Chat App with Agora in IOS]]></title>
            <link>https://medium.com/@sanufaris5/implementation-of-one-to-one-video-chat-app-with-agora-in-ios-5bf59e78231c?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bf59e78231c</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Mon, 30 Mar 2020 10:11:21 GMT</pubDate>
            <atom:updated>2020-03-30T10:11:21.404Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey guys! I am going to show you how you can make your own one-to- one video calling app using simple methods. Just follow the steps:</p><h4>Requirements</h4><ul><li>Xcode 9.0 or later</li><li>Agora account</li><li>An IOS device</li></ul><h4>Creating an IOS Project</h4><ol><li>First, open <strong>Xcode</strong> and click on <strong>Create a new Xcode project.</strong></li><li>Then choose the template, <strong>Single View App</strong> and then click <strong>Next</strong>.</li><li>Now choose the storage path for your project and click <strong>Create</strong>.</li><li>Connect the IOS device you have to the computer.</li><li>Navigate to <strong>TARGETS&gt;Project Name&gt;General&gt;Signing </strong>and choose <strong>Automatic manage signing</strong>.</li><li>A pop-up window will appear. Now click <strong>Enable Automatic</strong> in the pop-up window.</li></ol><h4>Integrating the SDK</h4><ol><li>For this, you need to have <strong>CocoaPods</strong> installed. If not, check out the installation guide(<a href="https://guides.cocoapods.org/using/getting-started.html#getting-started">https://guides.cocoapods.org/using/getting-started.html</a>)</li><li>In the <strong>Terminal</strong>, navigate to the path of your project.</li><li>Now, to create a <strong>Podfile</strong> in the project folder, run the <em>pod init </em>command.</li><li>Then, open the <strong>Podfile</strong> and delete all the contents in the <strong>Podfile</strong> and input the following commands. Also change Your App to the target name of the project.</li></ol><blockquote># platform :ios, ‘9.0&#39; use_frameworks!</blockquote><blockquote>target ‘Your App’ do</blockquote><blockquote>pod ‘AgoraRtcEngine_iOS’</blockquote><blockquote>end</blockquote><p>5. Now, run the <em>pod update</em> command in the <strong>Terminal</strong> for updating all the local libraries.</p><p>6. To install the <strong>Agora SDK</strong>, run the <em>pod install</em> command in the Terminal.</p><p>7. After completing installation, it shows <em>Pod installation complete!</em> And you will find a <strong>xcworkspace</strong> file in your project folder.</p><p>8. In <strong>Xcode</strong>, open the generated <strong>xcworkspace </strong>file.</p><h4>Adding Project Permissions</h4><p>We need to add the following permissions in the <strong>info.plist</strong> file for accessing device according to your requirements.</p><blockquote>Privacy — Microphone Usage Description	String	To access the microphone, such as for a call.</blockquote><blockquote>Privacy — Camera Usage Description</blockquote><h4>Before adding permissions:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*UiTHDHN1-gpquzeM8Elqig@2x.jpeg" /></figure><h4>After adding permissions:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*YlAfC51xQwzMEO3CAmX-4Q@2x.jpeg" /></figure><h4>Implementing the Video Calling Function</h4><h4>1. Creating UI</h4><p>First, create an <strong>User Interface (UI)</strong> in your project. Add the following elements into the <strong>UI:</strong></p><ul><li>Local video view</li><li>Remote video view</li><li>End-call button</li></ul><h4>2. Importing the class</h4><p>Next step is to import the <strong>AgoraRtcKit</strong> class in the project.</p><blockquote>// Objective-C</blockquote><blockquote>// As of v3.0.0, the SDK uses the AgoraRtcKit object.</blockquote><blockquote>#import &lt;AgoraRtcKit/AgoraRtcEngineKit.h&gt;</blockquote><blockquote>// The SDK of a version earlier than v3.0.0 uses the AgoraRtcEngineKit object.</blockquote><blockquote>#import &lt;AgoraRtcEngineKit/AgoraRtcEngineKit.h&gt;</blockquote><blockquote>// Swift</blockquote><blockquote>// As of v3.0.0, the SDK uses the AgoraRtcKit object.</blockquote><blockquote>import AgoraRtcKit</blockquote><blockquote>// The SDK of a version earlier than v3.0.0 uses the AgoraRtcEngineKit object.</blockquote><blockquote>import AgoraRtcEngineKit</blockquote><h4>3. Initializing Agora RtcEngineKit</h4><p>Before calling any other Agora APIs, we need to create and initialize the <strong>AgoraRtcEngineKit</strong>. For that we need to use the <strong>App ID</strong> of your project.</p><ol><li>After creating an Agora account, goto <strong>Console</strong> and click on <strong>Project Management.</strong></li><li>Now, click <strong>Create</strong> and set a project name and choose an authentication system. And click <strong>Submit</strong>.</li><li>You will find your <strong>App ID</strong> on the <strong>Project Management</strong> page.</li></ol><p>Next step is to call <strong>sharedEngineWithAppId</strong> method and then pass the <strong>App ID</strong> to initialize <strong>AgoraRtcEngineKit</strong> object.</p><blockquote>// Objective-C</blockquote><blockquote>(void)initializeAgoraEngine {</blockquote><blockquote>// Input your App ID to initialize the AgoraRtcEngineKit object.</blockquote><blockquote>self.agoraKit = [AgoraRtcEngineKit sharedEngineWithAppId:appID delegate:self];</blockquote><blockquote>}</blockquote><blockquote>// Swift</blockquote><p>func initializeAgoraEngine() {</p><blockquote>// Initialize the AgoraRtcEngineKit object.</blockquote><blockquote>agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: AppID, delegate: self)</blockquote><blockquote>}</blockquote><h4>4. Setting Up the Local Video View</h4><p>We need to set the local video view before joining the channel so you can see yourself in the call. To configure the local video view,</p><ul><li>Enable the video module by calling <strong>enableVideo</strong> method.</li><li>Configure the local video display settings by calling <strong>setupLocalVideo</strong> method.</li></ul><p>// Objective-C</p><blockquote>(void)setupVideo {</blockquote><blockquote>// Enable the video</blockquote><blockquote>[self.agoraKit enableVideo];</blockquote><blockquote>}</blockquote><blockquote>- (void)setupLocalVideo {</blockquote><blockquote>AgoraRtcVideoCanvas *videoCanvas = [[AgoraRtcVideoCanvas alloc] init];</blockquote><blockquote>videoCanvas.uid = 0;</blockquote><blockquote>videoCanvas.view = self.localVideo;</blockquote><blockquote>videoCanvas.renderMode = AgoraVideoRenderModeHidden;</blockquote><blockquote>// Set the local video view.</blockquote><blockquote>[self.agoraKit setupLocalVideo:videoCanvas];</blockquote><blockquote>}</blockquote><blockquote>// Swift</blockquote><p>func setupVideo() {</p><blockquote>// Enable the video</blockquote><blockquote>agoraKit.enableVideo()</blockquote><blockquote>}</blockquote><blockquote>func setupLocalVideo() {</blockquote><blockquote>let videoCanvas = AgoraRtcVideoCanvas()</blockquote><blockquote>videoCanvas.uid = 0</blockquote><blockquote>videoCanvas.view = localVideo</blockquote><blockquote>videoCanvas.renderMode = .hidden</blockquote><blockquote>// Set the local video view.</blockquote><blockquote>agoraKit.setupLocalVideo(videoCanvas)</blockquote><blockquote>}</blockquote><h4>5. Joining a Channel</h4><p>To join a channel, you can call the joinChannelByToken method. You need to set the following parameters:</p><ul><li><strong>channelId</strong>: You need to specify the channel you want to join and input your <strong>channelId</strong> before running the code.</li><li>token: pass a token that identifies a users privileges and roles. You can set the token as given below:</li></ul><p><strong>—</strong> <strong>nil.</strong></p><p><strong>—</strong> A temporary token generated in console which valid for only 24 hours. For more info:(<a href="https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token">https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token</a>)</p><p><strong>—</strong> Token generated at the server. For more info:(<a href="https://docs.agora.io/en/Video/token_server">https://docs.agora.io/en/Video/token_server</a>)</p><p><strong>—</strong> <strong>uid</strong>: It is the ID of a local user. It is an integer and it must be unique. If the uid is set to 0, then the SDK assigns user ID for the local user and returns it in the joinSuccessBlock callback.</p><p><strong>— joinSuccessBlock</strong>: It returns that the user joins the specified channel. For more info:(<a href="https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/joinChannelByToken:channelId:info:uid:joinSuccess:">https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/joinChannelByToken:channelId:info:uid:joinSuccess:</a>)</p><p>// Objective-C</p><blockquote>(void)joinChannel {</blockquote><blockquote>// Join a channel with a token.</blockquote><blockquote>[self.agoraKit joinChannelByToken:token channelId:@”demoChannel1&quot; info:nil uid:0 joinSuccess:^(NSString *channel, NSUInteger uid, NSInteger elapsed) {</blockquote><blockquote>}];</blockquote><blockquote>}</blockquote><blockquote>// Swift</blockquote><blockquote>func joinChannel() {</blockquote><blockquote>// Join a channel with a token.</blockquote><blockquote>agoraKit.joinChannel(byToken: Token, channelId: “demoChannel1&quot;, info:nil, uid:0) { [unowned self] (channel, uid, elapsed) -&gt; Void in}</blockquote><blockquote>self.isLocalVideoRender = true</blockquote><blockquote>self.logVC?.log(type: .info, content: “did join channel”)</blockquote><blockquote>}</blockquote><blockquote>isStartCalling = true</blockquote><blockquote>}</blockquote><h4>6. Setting Up the Remote Video View</h4><p>To see other users in a video call, we call <strong>setupRemoteVideo</strong> method after joining channel.</p><p>The <strong>SDK</strong> gets the remote user’s ID in the <strong>firstRemoteVideoDecodedOfUid</strong> call back when a remote user joins the channel.</p><p>Next step is to call the <strong>setupRemoteVideo</strong> method in the callback and pass in the <strong>uid</strong> for for setting up the video view of the remote user.</p><blockquote>// Objective-C</blockquote><blockquote>// Listen for the firstRemoteVideoDecodedOfUid callback.</blockquote><blockquote>// This callback occurs when the first video frame of a remote user is received and decoded after the remote user successfully joins the channel.</blockquote><blockquote>// You can call the setupRemoteVideo method in this callback to set up the remote video view.</blockquote><blockquote>(void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size: (CGSize)size elapsed:(NSInteger)elapsed {</blockquote><blockquote>if (self.remoteVideo.hidden) {</blockquote><blockquote>self.remoteVideo.hidden = NO;</blockquote><blockquote>}</blockquote><blockquote>AgoraRtcVideoCanvas *videoCanvas = [[AgoraRtcVideoCanvas alloc] init];</blockquote><blockquote>videoCanvas.uid = uid;</blockquote><blockquote>videoCanvas.view = self.remoteVideo;</blockquote><blockquote>videoCanvas.renderMode = AgoraVideoRenderModeHidden;</blockquote><blockquote>// Set the remote video view.</blockquote><blockquote>[self.agoraKit setupRemoteVideo:videoCanvas];</blockquote><blockquote>}</blockquote><blockquote>// Swift</blockquote><blockquote>// Listen for the firstRemoteVideoDecodedOfUid callback.</blockquote><blockquote>// This callback occurs when the first video frame of a remote user is received and decoded after the remote user successfully joins the channel.</blockquote><blockquote>// You can call the setupRemoteVideo method in this callback to set up the remote video view.</blockquote><blockquote>func rtcEngine(_ engine: AgoraRtcEngineKit, firstRemoteVideoDecodedOfUid uid:UInt, size:CGSize, elapsed:Int) {</blockquote><blockquote>isRemoteVideoRender = true</blockquote><blockquote>let videoCanvas = AgoraRtcVideoCanvas()</blockquote><blockquote>videoCanvas.uid = uid</blockquote><blockquote>videoCanvas.view = remoteVideo</blockquote><blockquote>videoCanvas.renderMode = .hidden</blockquote><blockquote>// Set the remote video view.</blockquote><blockquote>agoraKit.setupRemoteVideo(videoCanvas)</blockquote><blockquote>}</blockquote><h4>7. Leaving the Channel</h4><p>To leave the current call, we call <strong>leaveChannel</strong> method.</p><blockquote>// Objective-C</blockquote><blockquote>(void)leaveChannel {</blockquote><blockquote>// Leave the channel.</blockquote><blockquote>[self.agoraKit leaveChannel:^(AgoraChannelStats *stat)</blockquote><blockquote>}</blockquote><blockquote>// Swift</blockquote><blockquote>func leaveChannel() {</blockquote><blockquote>// Leave the channel.</blockquote><blockquote>agoraKit.leaveChannel(nil)</blockquote><blockquote>isRemoteVideoRender = false</blockquote><blockquote>isLocalVideoRender = false</blockquote><blockquote>isStartCalling = false</blockquote><blockquote>self.logVC?.log(type: .info, content: “did leave channel”)</blockquote><blockquote>}</blockquote><p>Thats all. Now all you have to do is run the project on your iOS device.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bf59e78231c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing an One-to-Many Video App in IOS using Agora]]></title>
            <link>https://medium.com/@sanufaris5/implementing-an-one-to-many-video-app-in-ios-using-agora-4feaf5a2b710?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/4feaf5a2b710</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 06:04:53 GMT</pubDate>
            <atom:updated>2020-03-29T06:04:53.398Z</atom:updated>
            <content:encoded><![CDATA[<p>To build this app in IOS, you must have,</p><ul><li>An IOS device.</li><li>Xcode 10.0+</li><li>CocoaPods(<a href="https://www.raywenderlich.com/464-storyboards-tutorial-for-ios-part-1">https://guides.cocoapods.org/using/getting-started.html</a>)</li><li>Agora account(<a href="https://www.raywenderlich.com/464-storyboards-tutorial-for-ios-part-1">https://sso.agora.io/en/signup</a>)</li><li>Knowledge in building IOS layouts using Storyboard(<a href="https://www.raywenderlich.com/464-storyboards-tutorial-for-ios-part-1">https://www.raywenderlich.com/464-storyboards-tutorial-for-ios-part-1</a>)</li></ul><h4>Set up Agora Library using CocoaPods</h4><ol><li>First step is to create a Xcode project. If you have an existing project, you can use that.</li><li>Open terminal and go to the root directory of the project.</li><li>Now run <em>pod init </em>to initialize the <strong>CocoaPods.</strong></li><li>Next step is to open the Podfile and add the codes given below for importing the Agora library.</li></ol><blockquote>target ‘Your App’ do</blockquote><blockquote>pod ‘AgoraRtcEngine_iOS’</blockquote><blockquote>end</blockquote><p>5. In the terminal, <em>run pod</em> install to install the library.</p><p>6. Open <strong>YourApp.xcworkspace</strong> for editing and running the app.</p><h4>Adding Permission for Camera and Microphone Access</h4><p>To get access to Microphone and Camera, add the keys given below in your <strong>Info.plist</strong></p><blockquote>Privacy — Microphone Usage Description</blockquote><blockquote>Privacy — Camera Usage Description</blockquote><p>Don’t forget to add values for each because they are user-facing and will be displayed when app asks permission from user.</p><h4>Set up the Scene</h4><p>We need to add the views that Agora will use to display video feeds in the <strong>Main.storyboard</strong>. Here, I’ll be using a single large view for displaying the local feed and a collection view for showing number of remote users. But you can adjust according to your requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*iV9Bjj5R1zvAN50YTRf8_A@2x.jpeg" /></figure><p>Here, the green colored colored part is local view and the red colored part is remote view template.</p><p>Now we have to add a View object for local stream, an UICollectionView for holding the remote streams and finally an UIButton to mute and hang up the call.</p><p>Now hook up the views in your main View Controller and then set the View Controller as UICollectionView’s datasource and delegate:</p><blockquote>class AgoraVideoViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {</blockquote><blockquote>@IBOutlet weak var collectionView: UICollectionView!</blockquote><blockquote>@IBOutlet weak var localVideoView: UIView!</blockquote><blockquote>@IBOutlet weak var muteButton: UIButton!</blockquote><blockquote>@IBOutlet weak var hangUpButton: UIButton!</blockquote><p>Now, you have to connect up your custom collection view cell:</p><blockquote>class VideoCollectionViewCell: UICollectionViewCell {</blockquote><blockquote>@IBOutlet weak var videoView: UIView!</blockquote><blockquote>@IBOutlet weak var nameplateView: UIView!</blockquote><blockquote>@IBOutlet weak var usernameLabel: UILabel!</blockquote><blockquote>}</blockquote><h4>Initializing Agora Engine</h4><p>For this we must create an instance of <strong>AgoraRtcEngineKit</strong> using our app ID. App ID can be retrieved from the Agora Dashboard when a new project is created.</p><p>First, we need to initialize a shared Agora engine by creating a helper function that initializes the engine.</p><blockquote>import AgoraRtcEngineKit</blockquote><blockquote>let appID = “YourAppIDHere”</blockquote><blockquote>var agoraKit: AgoraRtcEngineKit?</blockquote><blockquote>let tempToken: String? = nil //If you have a token, put it here.</blockquote><blockquote>var userID: UInt = 0 //This tells Agora to generate an id for you. If you have unique user IDs already, you can use those.</blockquote><blockquote>…</blockquote><blockquote>private func getAgoraEngine() -&gt; AgoraRtcEngineKit {</blockquote><blockquote>if agoraKit == nil {</blockquote><blockquote>agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: appID, delegate: self)</blockquote><blockquote>}</blockquote><blockquote>return agoraKit!</blockquote><blockquote>}</blockquote><p>We should implement the <strong>AgoraRtcEngineDelegate</strong> protocol so that we can respond to the relevant call backs.</p><blockquote>extension AgoraVideoViewController: AgoraRtcEngineDelegate {</blockquote><blockquote>}</blockquote><h4>Enabling Video</h4><p>For enabling video and telling Agora where to put local video stream, we call the function given below from <strong>viewDidLoad()</strong>.</p><blockquote>func setUpVideo() {</blockquote><blockquote>getAgoraEngine().enableVideo()</blockquote><blockquote>let videoCanvas = AgoraRtcVideoCanvas()</blockquote><blockquote>videoCanvas.uid = userID</blockquote><blockquote>videoCanvas.view = localVideoView</blockquote><blockquote>videoCanvas.renderMode = .fit</blockquote><blockquote>getAgoraEngine().setupLocalVideo(videoCanvas)</blockquote><blockquote>}</blockquote><h4>Joining a Channel</h4><p>After initializing the engine, we call <strong>joinChannel()</strong> for joining a call on the Agora engine.</p><blockquote>var channelName = “default”</blockquote><blockquote>func joinChannel() {</blockquote><blockquote>localVideoView.isHidden = false</blockquote><blockquote>getAgoraEngine().joinChannel(byToken: tempToken, channelId: channelName, info: nil, uid: userID) { [weak self] (sid, uid, elapsed) in</blockquote><blockquote>self?.userID = uid</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><h4>Set up Remote Video</h4><p>We need to keep the list of remote user IDs and set up remote video canvas for each one within our collection. For that, we use <strong>UICollectionView</strong>.</p><blockquote>var remoteUserIDs: [UInt] = []</blockquote><blockquote>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {</blockquote><blockquote>return remoteUserIDs.count</blockquote><blockquote>}</blockquote><blockquote>func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {</blockquote><blockquote>let cell = collectionView.dequeueReusableCell(withReuseIdentifier: “videoCell”, for: indexPath)</blockquote><blockquote>let remoteID = remoteUserIDs[indexPath.row]</blockquote><blockquote>if let videoCell = cell as? VideoCollectionViewCell {</blockquote><blockquote>let videoCanvas = AgoraRtcVideoCanvas()</blockquote><blockquote>videoCanvas.uid = remoteID</blockquote><blockquote>videoCanvas.view = videoCell.videoView</blockquote><blockquote>videoCanvas.renderMode = .fit</blockquote><blockquote>getAgoraEngine().setupRemoteVideo(videoCanvas)</blockquote><blockquote>}</blockquote><p>To get the list of userIDs and maintaining it, we need to use the <strong>rtcEngine(didJoinedOfUid:)</strong> and <strong>rtcEngine(didOfflineOfUid:)</strong> callbacks.</p><p>Add the following functions in <strong>AgoraRtcEngineDelegate</strong> extension.</p><blockquote>extension AgoraVideoViewController: AgoraRtcEngineDelegate {</blockquote><blockquote>func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinedOfUid uid: UInt, elapsed: Int) {</blockquote><blockquote>remoteUserIDs.append(uid)</blockquote><blockquote>collectionView.reloadData()</blockquote><blockquote>}</blockquote><blockquote>func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason) {</blockquote><blockquote>if let index = remoteUserIDs.firstIndex(where: { $0 == uid }) {</blockquote><blockquote>remoteUserIDs.remove(at: index)</blockquote><blockquote>collectionView.reloadData()</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>And now , you have a video chat app.</p><h4>Polishing the App</h4><p>We must add some functions so that our app looks perfect. Right now, our buttons don’t do anything. Let’s start by enabling the mute button by calling <strong>muteLocalAudioStream()</strong>:</p><blockquote>var muted = false {</blockquote><blockquote>didSet {</blockquote><blockquote>if muted {</blockquote><blockquote>muteButton.setTitle(“Unmute”, for: .normal)</blockquote><blockquote>} else {</blockquote><blockquote>muteButton.setTitle(“Mute”, for: .normal)</blockquote><blockquote>}</blockquote><p>}</p><blockquote>}</blockquote><blockquote>@IBAction func didToggleMute(_ sender: Any) {</blockquote><blockquote>if muted {</blockquote><blockquote>getAgoraEngine().muteLocalAudioStream(false)</blockquote><blockquote>} else {</blockquote><blockquote>getAgoraEngine().muteLocalAudioStream(true)</blockquote><blockquote>}</blockquote><blockquote>muted = !muted</blockquote><blockquote>}</blockquote><p>We can hang up the call by calling <strong>leaveChannel()</strong>;</p><blockquote>@IBAction func didTapHangUp(_ sender: Any) {</blockquote><blockquote>leaveChannel()</blockquote><blockquote>}</blockquote><blockquote>func leaveChannel() {</blockquote><blockquote>getAgoraEngine().leaveChannel(nil)</blockquote><blockquote>localVideoView.isHidden = true</blockquote><blockquote>remoteUserIDs.removeAll()</blockquote><blockquote>collectionView.reloadData()</blockquote><blockquote>}</blockquote><p>The last step is joining the channels with a username to give our remote streams few nameplates. If you have an username, you can join using this by updating <strong>joinChannel()</strong>.</p><blockquote>func joinChannel() {</blockquote><blockquote>localVideoView.isHidden = false</blockquote><blockquote>if let name = userName {</blockquote><blockquote>getAgoraEngine().joinChannel(byUserAccount: name, token: tempToken, channelId: channelName) { [weak self] (sid, uid, elapsed) in</blockquote><blockquote>self?.userID = uid</blockquote><blockquote>}</blockquote><blockquote>} else {</blockquote><blockquote>getAgoraEngine().joinChannel(byToken: tempToken, channelId: channelName, info: nil, uid: userID) { [weak self] (sid, uid, elapsed) in</blockquote><blockquote>self?.userID = uid</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>If a remote user joins, we can extract the username by adding the following codes to <strong>collectionView(cellForItemAt:)</strong></p><blockquote>if let userInfo = getAgoraEngine().getUserInfo(byUid: remoteID, withError: nil),</blockquote><blockquote>let username = userInfo.userAccount {</blockquote><blockquote>videoCell.nameplateView.isHidden = false</blockquote><blockquote>videoCell.usernameLabel.text = username</blockquote><blockquote>} else {</blockquote><blockquote>videoCell.nameplateView.isHidden = true</blockquote><blockquote>}</blockquote><p>And now you have a perfect video calling app of your own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4feaf5a2b710" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Video Calling functionality in Agora for Android]]></title>
            <link>https://medium.com/@sanufaris5/implementing-video-calling-functionality-in-agora-for-android-fe43670316db?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe43670316db</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Sat, 28 Mar 2020 07:46:19 GMT</pubDate>
            <atom:updated>2020-03-28T07:46:19.312Z</atom:updated>
            <content:encoded><![CDATA[<p>I am going to tell you guys how to easily implement video calling function in Agora for Android. Just follow the steps below:</p><h3>Setting up a New Project</h3><ol><li>First, open Android Studio and click on <strong>Start a new Android Studio project.</strong></li><li>Now, click on <strong>Choose your project panel</strong> and choose <strong>Phone and Tablet&gt;Empty Activity</strong> and click <strong>Next</strong>.</li><li>Now click <strong>Finish.</strong></li></ol><h3>Integrating the Agora SDK</h3><p>Now we have to integrate the <strong>Agora SDK</strong>. For that we need to add the line given below in the <strong>/app/build.gradle</strong> file of your project.</p><p><em>…</em></p><p><em>dependencies {</em></p><p><em>…</em></p><p><em>// 2.9.2 is the latest version of the Agora SDK. You can set it to other versions.</em></p><p><em>implementation ‘io.agora.rtc:full-sdk:2.9.2’</em></p><p><em>implementation ‘io.agora.rtm:rtm-sdk:1.1.0’</em></p><p><em>implementation ‘com.google.firebase:firebase-analytics:17.2.0’</em></p><p><em>implementation ‘com.google.firebase:firebase-auth:19.1.0’</em></p><p><em>implementation ‘com.google.android.gms:play-services-auth:17.0.0’</em></p><blockquote><em>…</em></blockquote><p><em>}</em></p><p><em>apply plugin: ‘com.google.gms.google-services’</em></p><p>Now add the project permissions in the <strong>/app/src/main/AndroidManifest.xml</strong> file for device access according to you needs.</p><p><em>&lt;manifest xmlns:android=”http://schemas.android.com/apk/res/android”</em></p><p><em>package=”com.example.whatsappagora”&gt;. &lt;uses-permission android:name=”android.permission.READ_PHONE_STATE” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.INTERNET” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.RECORD_AUDIO” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.CAMERA” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.BLUETOOTH” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” /&gt;</em></p><p><em>&lt;uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” /&gt;</em></p><blockquote><em>…</em></blockquote><p><em>&lt;/manifest&gt;</em></p><p>To prevent code obfuscation just add the line give below in the <strong>app/proguard-rules.pro</strong> file.</p><p><em>-keep class io.agora.**{*;}</em></p><h3>Set up Sign-in</h3><p>We need to allow users to log in to our app using their Google account like most of the social media applications. We can the following line to start Google authentication process:</p><p><em>Intent sianInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);</em></p><p><em>startActivityForResult(sianInIntent, RC_SIGN_IN);</em></p><p>Also check out the following link to implement Google authentication: <a href="https://youtu.be/SXlidHy-Tb8">https://youtu.be/SXlidHy-Tb8</a></p><h4>Implementing Video Call Function</h4><p>We use the <strong>Agora Video SDK</strong> for implementing this functionality. Now, let us add the video logic to the application.</p><h4>Channel Selection</h4><p>Let’s implement <strong>onClickListener</strong> of call button that we have in the Channel Selection activity. When the user clicks the call button, if the user is in the group chat mode, we use the channel name one user inputed in the <strong>EditText. </strong>Or if the user is in peer-to-peer mode, the channel name will be sorted combination of use Google display. Now we pass channel name, user information and call mode to Video Call Activity.</p><blockquote>public void onClickCall(View view) {</blockquote><blockquote>String myName = user.getFireDisplayName();</blockquote><blockquote>mTargetName = mNameEditText.getText().toString();</blockquote><p>…</p><blockquote>String channelName = “”;</blockquote><blockquote>if (mIsPeerToPeerMode) {</blockquote><blockquote>channelName = myName.compareTo(mTargetName) &lt; 0 ? myName + mTargetName : mTargetName + myName;</blockquote><blockquote>}else {</blockquote><blockquote>channelName = mTargetName;</blockquote><blockquote>}</blockquote><blockquote>Intent intent = new Intent(this, VideoActivity.class);</blockquote><blockquote>…</blockquote><blockquote>startActivity(intent);</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><h4>Video Call Activity</h4><p>Create the UI components in this activity: start_call/end_call, switch_camera and an audio_mute/audio_unmute button.</p><p>Now, we have to do the following things in <strong>onCreate() </strong>method in Video Call activity:</p><h4>1. Initializing Agora Rtc Engine</h4><p>For this, all you need to do is just call <strong>RtcEngine.create(context, appid, RtcEventHandler) </strong>to create <strong>RtmClient</strong> instance.</p><blockquote>mRtcEngine = RtcEngine.create(getBaseContext(), appID, mRtcEventHandler);</blockquote><p>Now let’s implement different events on the <strong>RtcEngine</strong> using basic event handlers needed for this application.</p><p>private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {</p><blockquote>@Override</blockquote><blockquote>// Listen for the onJoinChannelSuccess callback.</blockquote><blockquote>// This callback occurs when the local user successfully joins the channel.</blockquote><blockquote>public void onJoinChannelSuccess(String channel, final int uid, int elapsed) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>user.setAgoraUid(uid);</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>} @Override</blockquote><blockquote>// Listen for the onFirstRemoteVideoDecoded callback.</blockquote><blockquote>// This callback occurs when the first video frame of a remote user is received and decoded after the remote user successfully joins the channel.</blockquote><blockquote>// You can call the setupRemoteVideo method in this callback to set up the remote video view.</blockquote><blockquote>public void onFirstRemoteVideoDecoded(final int uid, int width, int height, int elapsed) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>SurfaceView mRemoteView = RtcEngine.CreateRendererView(getApplicationContext());</blockquote><blockquote>…</blockquote><blockquote>mRtcEngine.setupRemoteVideo(new VideoCanvas(mRemoteView, VideoCanvas.RENDER_MODE_HIDDEN, uid));</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>} @Override</blockquote><blockquote>// Listen for the onUserOffline callback.</blockquote><blockquote>// This callback occurs when the remote user leaves the channel or drops offline.</blockquote><blockquote>public void onUserOffline(final int uid, int reason) { … }</blockquote><blockquote>};</blockquote><h4>2. Setting Up Local Video Canvas</h4><p>You must call two functions to start a local video call: <strong>enableVideo()</strong> and <strong>setupLocalVideo()</strong> on <strong>RtcEngine</strong> instance.</p><p>In <strong>setupLocalVideo</strong>() function, a <strong>surfaceView</strong> is passed as parameter created by calling <strong>RtcEngine.CreateRendorView(context).</strong></p><blockquote>mRtcEngine.enableVideo();</blockquote><blockquote>SurfaceView surfaceView = RtcEngine.CreateRendererView(getBaseContext());</blockquote><blockquote>mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, 0));</blockquote><h4>3. Joining a Channel</h4><p>Next step is to join a channel by calling <strong>joinChannel()</strong> on the <strong>RtcEngine</strong> instance and pass the channel name.</p><blockquote>mRtcEngine.joinChannel(token, channelName, “Extra Optional Data”, 0);</blockquote><p>Now, the <strong>RtcEngineEventHandler</strong> will trigger <strong>onJoinChannelSuccess()</strong> method. It will return the Agora Video ID in which we store the user informations.</p><h4>Implementing Buttons onClick</h4><p>We need to implement logic for three buttons in this activity.</p><h4>1. Start/end a call</h4><p>If we are in a call, when we click the start/end call button, we must finish the video call by calling <strong>leaveChannel()</strong>. Or else we will start a call by setting up the local video and joins the channel.</p><h4>2. Switching the Camera</h4><p>For using the switch camera button, we need to call <strong>switchCamera() </strong>on <strong>RtcEngine</strong> instance.</p><blockquote>mRtcEngine.switchCamera();</blockquote><h4>3. Audio mute/unmute</h4><p>This button is implemented by calling the <strong>muteLocalAudioStream() </strong>on <strong>RtcEngine</strong> instance and then passing whether the user already muted.</p><blockquote>mRtcEngine.muteLocalAudioStream(isMuted);</blockquote><p>Thats all. You have successfully created your own video calling app in android.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe43670316db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing chat function in Agora for Android]]></title>
            <link>https://medium.com/@sanufaris5/implementing-chat-function-in-agora-for-android-1a640f0541a1?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a640f0541a1</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Fri, 27 Mar 2020 14:25:47 GMT</pubDate>
            <atom:updated>2020-03-27T14:25:47.777Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story, I am going to tell you guys how to easily implement chat function in Agora for Android. Just follow the steps:</p><h3>Setting up a New Project</h3><ol><li>First, open Android Studio and click on <strong>Start a new Android Studio project.</strong></li><li>Now, click on <strong>Choose your project panel</strong> and choose <strong>Phone and Tablet&gt;Empty Activity</strong> and click <strong>Next</strong>.</li><li>Now click <strong>Finish.</strong></li></ol><h3>Integrating the Agora SDK</h3><p>Next step is to integrate the <strong>Agora SDK</strong>. For that we have to add the line given below in the <strong>/app/build.gradle</strong> file of your project.</p><blockquote>…</blockquote><blockquote>dependencies {</blockquote><blockquote>…</blockquote><blockquote>// 2.9.2 is the latest version of the Agora SDK. You can set it to other versions.</blockquote><blockquote>implementation ‘io.agora.rtc:full-sdk:2.9.2&#39;</blockquote><blockquote>implementation ‘io.agora.rtm:rtm-sdk:1.1.0&#39;</blockquote><blockquote>implementation ‘com.google.firebase:firebase-analytics:17.2.0&#39;</blockquote><blockquote>implementation ‘com.google.firebase:firebase-auth:19.1.0&#39;</blockquote><blockquote>implementation ‘com.google.android.gms:play-services-auth:17.0.0&#39;</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><blockquote>apply plugin: ‘com.google.gms.google-services’</blockquote><p>Now add the project permissions in the <strong>/app/src/main/AndroidManifest.xml</strong> file for device access according to you needs.</p><blockquote>&lt;manifest xmlns:android=”http://schemas.android.com/apk/res/android”</blockquote><blockquote>package=”com.example.whatsappagora”&gt;. &lt;uses-permission android:name=”android.permission.READ_PHONE_STATE” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.INTERNET” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.RECORD_AUDIO” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.CAMERA” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.BLUETOOTH” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” /&gt;</blockquote><blockquote>…</blockquote><blockquote>&lt;/manifest&gt;</blockquote><p>To prevent code obfuscation just add the line give below in the <strong>app/proguard-rules.pro</strong> file.</p><blockquote>-keep class io.agora.**{*;}</blockquote><h3>Setting up Sign-in</h3><p>We want to allow users to log in to our app using their Google account like most of the social media applications. We can the following line to start Google authentication process:</p><blockquote>Intent sianInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);</blockquote><blockquote>startActivityForResult(sianInIntent, RC_SIGN_IN);</blockquote><p>Also check out the following link to implement Google authentication: <a href="https://youtu.be/SXlidHy-Tb8">https://youtu.be/SXlidHy-Tb8</a></p><h3>Implementation of Chatting Function</h3><h4>Starting RtmClient</h4><p>We need to create <strong>RtmClient</strong> in <strong>Agora Rtm SDK</strong> for enabling the chat function in the application.</p><blockquote>Rtmclient = RtmClient.createInstance(mContext, appID, new RtmClientListener() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onConnectionStateChanged(int state, int reason){</blockquote><blockquote>for (RtmClientListener listener : mListenerList) {</blockquote><blockquote>listener.onConnectionStateChanged(state, reason);</blockquote><blockquote>}</blockquote><blockquote>}@Override</blockquote><blockquote>public void onMessageReceived(RtmMessage rtmMessage, String peerId) { … }</blockquote><blockquote>});</blockquote><p>To get the <strong>App ID:</strong></p><ol><li>Create an <strong>Agora Project</strong> in the console.</li><li>Now click on <strong>Project Management</strong>.</li><li>Click <strong>Create</strong> and set project name and choose authentication mechanism and then click <strong>Submit.</strong></li><li>In the Project Management page, you can find the App ID of your project.</li></ol><p>After signing in through Google account, login to <strong>RtmClient</strong> using the Google display name.</p><blockquote>GoogleSignInApi.getSignInResultFromIntent(data);</blockquote><blockquote>if (result.isSuccess()) {</blockquote><blockquote>final User user = new User(result.getSignInAccount().getId());</blockquote><blockquote>user.setFireDisplayName(result.getSignInAccount()</blockquote><blockquote>getDisplayName());</blockquote><blockquote>mRtmClient.login(null, user.getFireDisplayName(), new io.agora.rtm.ResultCallback() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onSuccess(Void aVoid) { … } @Override</blockquote><blockquote>public void onFailure(final ErrorInfo errorInfo) { … }</blockquote><blockquote>});</blockquote><blockquote>}else {</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><p>Now we can pass the user information and jump to the Channel Selection activity in the <strong>onSuccess</strong>().</p><h4>Channel Selection</h4><p>First, we need to create an UI for Channel Selection with a group for users to choose chat in peer-to-peer mode or group mode, a chat button, an EditText view in order for users to input the channel name and a button to start a video calling process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*-lXzMchXd30uaJGT7ahDWg@2x.jpeg" /></figure><p>You can get the<strong> .xml</strong> file from <a href="https://github.com/ysc1995/WhatsappAgora/blob/master/app/src/main/res/layout/activity_channel_selection.xml">https://github.com/ysc1995/WhatsappAgora/blob/master/app/src/main/res/layout/activity_channel_selection.xml</a></p><h4>Message Activity</h4><p>In this, we create a <strong>RecyclerView</strong> to show the chat history, a send message button, an <strong>EditText</strong> for user input chat message and a <strong>TextView</strong> to show the name of chat room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*9MUEwUtIG9ies12pdcMHNA@2x.jpeg" /></figure><p>You can find the .<strong>xml</strong> file from <a href="https://github.com/ysc1995/WhatsappAgora/blob/master/app/src/main/res/layout/activity_message.xml">https://github.com/ysc1995/WhatsappAgora/blob/master/app/src/main/res/layout/activity_message.xml</a></p><p>In <strong>onCreate() </strong>method, we set the layout manager and adapter for <strong>RecyclerView</strong>.</p><h4>Receiving Group Chat Mesage</h4><p>For group chat, we call <strong>createChannel()</strong> on the <strong>RtmClient </strong>in <strong>onCreate()</strong> method.</p><blockquote>mRtmChannel = mRtmClient.createChannel(mChannelName, new MyChannelListener());</blockquote><p>Next step is to define the <strong>MyChannelListener</strong> which implements <strong>RtmChannelListener</strong> with callback <strong>onMessageRecieved() </strong>to handle the logic when we recieve messages sent by any members in the chat room.</p><blockquote>class MyChannelListener implements RtmChannelListener {</blockquote><blockquote>@Override</blockquote><blockquote>public void onMessageReceived(final RtmMessage message, final RtmChannelMember fromMember) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>String account = fromMember.getUserId();</blockquote><blockquote>String msg = message.getText();</blockquote><blockquote>MessageBean messageBean = new MessageBean(account, msg, false);</blockquote><blockquote>messageBean.setBackground(getMessageColor(account));</blockquote><blockquote>mMessageBeanList.add(messageBean);</blockquote><blockquote>mMessageAdapter.notifyItemRangeChanged(mMessageBeanList.size(), 1);</blockquote><blockquote>mRecyclerView.scrollToPosition(mMessageBeanList.size() — 1);</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><p>Now join the channel by calling <strong>join()</strong> on the <strong>RtmChannel</strong> instance.</p><blockquote>mRtmChannel.join(new ResultCallback() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onSuccess(Void responseInfo) { … } @Override</blockquote><blockquote>public void onFailure(ErrorInfo errorInfo) { … }</blockquote><blockquote>});</blockquote><p>To get the number of members in the chat room, we can call <strong>getMembers()</strong>on <strong>RtmChannel</strong> instance in the <strong>onSuccess()</strong> callback.</p><h4>Receiving Private Chat Message</h4><p>For receiving the private chat messages, we need to register <strong>RtmClientListener</strong>. We put the logic to show messages on the <strong>RecyclerView</strong> in the callback <strong>onMessageRecieved().</strong></p><blockquote>class MyRtmClientListener implements RtmClientListener {@Override</blockquote><blockquote>public void onConnectionStateChanged(final int state, int reason) { … }@Override</blockquote><blockquote>public void onMessageReceived(final RtmMessage message, final String peerId) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>String content = message.getText();</blockquote><blockquote>if (peerId.equals(mPeerId)) {</blockquote><blockquote>MessageBean messageBean = new MessageBean(peerId, content,false);</blockquote><blockquote>messageBean.setBackground(getMessageColor(peerId));</blockquote><blockquote>mMessageBeanList.add(messageBean);</blockquote><blockquote>mMessageAdapter.notifyItemRangeChanged(mMessageBeanList.size(), 1);</blockquote><blockquote>mRecyclerView.scrollToPosition(mMessageBeanList.size() — 1);</blockquote><blockquote>} else {</blockquote><blockquote>MessageUtil.addMessageBean(peerId, content);</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><h4>Sending Messages</h4><p>For this process, first we need create a message instance by calling <strong>createMessage().setText()</strong> on the <strong>RtmClient</strong> instance inthe send message button <strong>onClickListener()</strong> method.</p><blockquote>RtmMessage message = mRtmClient.createMessage().setText(userInputText);</blockquote><p>Now we want to send this message out to the <strong>SDK</strong>.</p><p>If we are in the group chat mode, we need to call <strong>sendMessage() </strong>on the <strong>RtmChannel</strong> instance.</p><blockquote>mRtmChannel.sendMessage(message, new ResultCallback() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onSuccess(Void aVoid) { … } @Override</blockquote><blockquote>public void onFailure(ErrorInfo errorInfo) { … }</blockquote><blockquote>});</blockquote><p>If we are in peer-to-peer mode, we need to call <strong>sendMessageToPeer().</strong></p><blockquote>mRtmClient.sendMessageToPeer(mPeerId, message, mChatManager.getSendMessageOptions(), new ResultCallback() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onSuccess(Void aVoid) { … } @Override</blockquote><blockquote>public void onFailure(ErrorInfo errorInfo) { … }</blockquote><blockquote>});</blockquote><h4>Handling onDestroy()</h4><p>This method is for unregistering unused listeners and leaving the channel in <strong>onDestroy()</strong> method.</p><blockquote>@Override</blockquote><blockquote>protected void onDestroy() {</blockquote><blockquote>super.onDestroy();</blockquote><blockquote>if (mIsPeerToPeerMode) { … }</blockquote><blockquote>else {</blockquote><blockquote>leaveChannel();</blockquote><blockquote>}</blockquote><blockquote>mChatManager.unregisterListener(mClientListener);</blockquote><blockquote>}/**</blockquote><blockquote>* API CALL: leave and release channel</blockquote><blockquote>*/</blockquote><blockquote>private void leaveChannel() {</blockquote><blockquote>if (mRtmChannel != null) {</blockquote><blockquote>mRtmChannel.leave(new ResultCallback() {</blockquote><blockquote>@Override</blockquote><blockquote>public void onSuccess(Void aVoid) { … } @Override</blockquote><blockquote>public void onFailure(ErrorInfo errorInfo) { … }</blockquote><blockquote>});</blockquote><blockquote>mRtmChannel = null;</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>Now we can chat with a friend or chat in chat room using the channel name.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a640f0541a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integration of Real-Time Video in Flutter]]></title>
            <link>https://medium.com/@sanufaris5/integration-of-voice-and-video-calling-in-flutter-6fb668ce8273?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb668ce8273</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Mon, 16 Mar 2020 07:55:29 GMT</pubDate>
            <atom:updated>2020-03-27T07:20:39.412Z</atom:updated>
            <content:encoded><![CDATA[<p>Many applications are now developed with the feature of voice and video calling facility. This makes users to interact easily from anywhere and any time they want.</p><p>Flutter is a cross-platform development framework created by Google to allow a single codebase for both iOS and Android applications.</p><p>Now let us look how to integrate video calling in flutter:</p><ol><li>First go to the <strong>Agora Flutter QuickStart</strong> <strong>GitHub repo (</strong><a href="https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2FAgoraIO-Community%2FAgora-Flutter-Quickstart%2F">https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2FAgoraIO-Community%2FAgora-Flutter-Quickstart%2F</a>)</li></ol><p>2. Now clone the project to a local directory.</p><p><strong>git clone</strong> :</p><blockquote>https://github.com/AgoraIO-Community/Agora-Flutter-Quickstart/</blockquote><p><strong>Directory:</strong></p><p><em>cd Agora-Flutter-Quickstart/</em></p><h3>Creating an account and getting App ID</h3><p>We need to have an Agora App ID to build and run the application.</p><ol><li>First, create an account in agora.io. After completion of registration, you will be redirected to the dashboard page.</li><li>Now goto <strong>Project&gt;Project List</strong> and copy the App ID.</li></ol><h3>Running the application</h3><p>You have to open <strong>settings.dart</strong> file and paste your App ID.</p><blockquote><strong>const</strong> APP_ID = “PASTE-APP-ID-HERE” ;</blockquote><p>To install the required dependencies, run ‘<em>packages get</em>’ command in the project directory.</p><blockquote>flutter packages <strong>get</strong></blockquote><p>Now execute the ‘<em>run</em>’ command to start the application.</p><p><em>flutter run</em></p><h3>Device Permission:</h3><h4>Andriod:</h4><p>Open the AndroidManifest.xml file and add the required device permissions to the file.</p><blockquote>..</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.READ_PHONE_STATE”/&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.INTERNET” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.RECORD_AUDIO” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.CAMERA” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /&gt;</blockquote><blockquote>&lt;! — The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices. — &gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.BLUETOOTH” /&gt;</blockquote><blockquote>..</blockquote><h4>Ios:</h4><p>Open the info.plist and add:</p><ul><li>Privacy — Microphone Usage Description, and add a note in the Value column.</li><li>Privacy — Camera Usage Description, and add a note in the Value column.</li></ul><p>That’s it. You’ve successfully integrated the video calling in flutter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb668ce8273" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a React Native Video Calling App Using Agora.io]]></title>
            <link>https://medium.com/@sanufaris5/building-a-react-native-video-calling-app-using-agora-io-24857590b5e5?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/24857590b5e5</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Mon, 16 Mar 2020 06:45:43 GMT</pubDate>
            <atom:updated>2020-03-16T07:58:37.872Z</atom:updated>
            <content:encoded><![CDATA[<p>In this, we’ll be using the Agora RTC SDK for React Native (<a href="https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2FAgoraIO-Community%2FAgora-Flutter-Quickstart%2F">https://www.npmjs.com/package/@zhigang1992/react-native-agora</a>) for building the app.</p><h3>1. Create an account in Agora</h3><ul><li>First, we have to sign up on Agora.io (<a href="https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2FAgoraIO-Community%2FAgora-Flutter-Quickstart%2F">https://sso.agora.io/en/signup</a>) and login to dashboard.</li><li>Next step is to create a new project and retrieve the App ID. This is used to authorize requests while developing the application.</li></ul><h3>2. Run the app</h3><ul><li>Make sure that you have installed the latest version of Node.js and NPM/Yarn.</li><li>You have to download and extract the zip file (<a href="https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2FAgoraIO-Community%2FAgora-Flutter-Quickstart%2F">https://github.com/EkaanshArora/Agora-React-Native-Demo</a>).</li><li>Run npm install.</li><li>Goto directory<strong><em> ./components/Home.js</em></strong> and edit the line 13 to enter your App ID.</li><li>Now open a terminal and execute <strong>react-native run-android</strong> / <strong>react-native run-ios</strong> to start the app.</li><li>Once the home screen becomes visible, enter a channel name and click submit.</li><li>Use the same channel on different device.</li><li>Done…</li></ul><h3>How it works</h3><h4>Permission.js</h4><p>We use this functions to request camera and microphone permissions from android and OS.</p><blockquote>import { PermissionsAndroid } from “react-native”;</blockquote><blockquote>export default async function requestCameraAndAudioPermission() {</blockquote><blockquote>try {</blockquote><blockquote>const granted = await PermissionsAndroid.requestMultiple([</blockquote><blockquote>PermissionsAndroid.PERMISSIONS.CAMERA,</blockquote><blockquote>PermissionsAndroid.PERMISSIONS.RECORD_AUDIO</blockquote><blockquote>]);</blockquote><blockquote>if (</blockquote><blockquote>granted[“android.permission.RECORD_AUDIO”] ===</blockquote><blockquote>PermissionsAndroid.RESULTS.GRANTED &amp;&amp;</blockquote><blockquote>granted[“android.permission.CAMERA”] ===</blockquote><blockquote>PermissionsAndroid.RESULTS.GRANTED</blockquote><blockquote>) {</blockquote><blockquote>console.log(“You can use the cameras &amp; mic”);</blockquote><blockquote>} else {</blockquote><blockquote>console.log(“Permission denied”);</blockquote><blockquote>}</blockquote><blockquote>} catch (err) {</blockquote><blockquote>console.warn(err);</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><h4>Router.js</h4><p>We use the router flux to navigate between the video call screen and landing page.</p><blockquote>import { Router, Scene, ActionConst } from ‘react-native-router-flux’;</blockquote><blockquote>import React from ‘react’;</blockquote><blockquote>import Video from ‘./Video’;</blockquote><blockquote>import Home from ‘./Home’;</blockquote><blockquote>const RouterComponent = () =&gt; (</blockquote><blockquote>&lt;Router&gt;</blockquote><blockquote>&lt;Scene&gt;</blockquote><blockquote>&lt;Scene key=”home” component={Home} title=”Agora Video Call” initial type={ActionConst.RESET} /&gt;</blockquote><blockquote>&lt;Scene key=”video” component={Video} title=”Video Feed” type={ActionConst.RESET} hideNavBar={true} /&gt;</blockquote><blockquote>&lt;/Scene&gt;</blockquote><blockquote>&lt;/Router&gt;</blockquote><blockquote>);</blockquote><blockquote>export default RouterComponent;</blockquote><h4>Home.js</h4><blockquote>import React, { Component } from ‘react’;</blockquote><blockquote>import { View, StyleSheet, Text, TextInput, TouchableOpacity, Platform } from ‘react-native’;</blockquote><blockquote>import { Actions } from ‘react-native-router-flux’;</blockquote><blockquote>import requestCameraAndAudioPermission from ‘./permission’;</blockquote><blockquote>class Home extends Component {</blockquote><blockquote>constructor(props) {</blockquote><blockquote>super(props);</blockquote><blockquote>this.state = {</blockquote><blockquote>AppID: ‘*INSERT APP ID HERE*’, //Set your APPID here</blockquote><blockquote>ChannelName: ‘’, //Set a default channel or leave blank</blockquote><blockquote>};</blockquote><blockquote>if (Platform.OS === ‘android’) { //Request required permissions from Android</blockquote><blockquote>requestCameraAndAudioPermission().then(_ =&gt; {</blockquote><blockquote>console.log(‘requested!’);</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>Now we have the import statements and set up our class based component Home. Our App ID and Channel Name is defined as state variables. We use the function from permission.js to access the camera and mic.</p><p>The Home component have two fields, to enter App ID and Channel name. Also a button to submit the data and start the call.</p><blockquote>….</blockquote><blockquote>handleSubmit = () =&gt; {</blockquote><blockquote>let AppID = this.state.AppID;</blockquote><blockquote>let ChannelName = this.state.ChannelName;</blockquote><blockquote>if (AppID !== ‘’ &amp;&amp; ChannelName !== ‘’) {</blockquote><blockquote>Actions.video({ AppID, ChannelName });</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>render() {</blockquote><blockquote>return (</blockquote><blockquote>&lt;View style={styles.container}&gt;</blockquote><blockquote>&lt;Text style={styles.formLabel}&gt;App ID&lt;/Text&gt;</blockquote><blockquote>&lt;TextInput</blockquote><blockquote>style={styles.formInput}</blockquote><blockquote>onChangeText={(AppID) =&gt; this.setState({ AppID })}</blockquote><blockquote>value={this.state.AppID}</blockquote><blockquote>/&gt;</blockquote><blockquote>&lt;Text style={styles.formLabel}&gt;Channel Name&lt;/Text&gt;</blockquote><blockquote>&lt;TextInput</blockquote><blockquote>style={styles.formInput}</blockquote><blockquote>onChangeText={(ChannelName) =&gt; this.setState({ ChannelName })}</blockquote><blockquote>value={this.state.ChannelName}</blockquote><blockquote>/&gt;</blockquote><blockquote>&lt;View style={styles.buttonContainer}&gt;</blockquote><blockquote>&lt;TouchableOpacity</blockquote><blockquote>title=”Start Call!”</blockquote><blockquote>onPress={this.handleSubmit}</blockquote><blockquote>style={styles.submitButton}</blockquote><blockquote>&gt;</blockquote><blockquote>&lt;Text style={{ color: ‘#ffffff’ }}&gt; Start Call &lt;/Text&gt;</blockquote><blockquote>&lt;/TouchableOpacity&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>);</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>const styles = StyleSheet.create({</blockquote><blockquote>container: {</blockquote><blockquote>justifyContent: ‘center’,</blockquote><blockquote>marginTop: 0,</blockquote><blockquote>padding: 20,</blockquote><blockquote>flex: 1,</blockquote><blockquote>backgroundColor: ‘#ffffff’,</blockquote><blockquote>},</blockquote><blockquote>formLabel: {</blockquote><blockquote>paddingBottom: 10,</blockquote><blockquote>paddingTop: 10,</blockquote><blockquote>color: ‘#0093E9&#39;,</blockquote><blockquote>},</blockquote><blockquote>buttonContainer: {</blockquote><blockquote>alignItems: ‘center’,</blockquote><blockquote>paddingTop: 20,</blockquote><blockquote>},</blockquote><blockquote>submitButton: {</blockquote><blockquote>paddingHorizontal: 60,</blockquote><blockquote>paddingVertical: 10,</blockquote><blockquote>backgroundColor: ‘#0093E9&#39;,</blockquote><blockquote>borderRadius: 25,</blockquote><blockquote>},</blockquote><blockquote>formInput: {</blockquote><blockquote>height: 40,</blockquote><blockquote>backgroundColor: ‘#f5f5f5&#39;,</blockquote><blockquote>color: ‘#0093E9&#39;,</blockquote><blockquote>borderRadius: 4,</blockquote><blockquote>paddingLeft: 20,</blockquote><blockquote>},</blockquote><p>});</p><blockquote>export default Home;</blockquote><p>Now we define the handleSubmit function to get the input values and pass them to the video.js component. Then we export the component to use with with the router.</p><h4>Video.js</h4><blockquote>import React, { Component } from ‘react’;</blockquote><blockquote>import { View, StyleSheet, NativeModules, Platform } from ‘react-native’;</blockquote><blockquote>import { RtcEngine, AgoraView } from ‘react-native-agora’;</blockquote><blockquote>import Icon from ‘react-native-vector-icons/MaterialIcons’;</blockquote><blockquote>import { Actions } from ‘react-native-router-flux’;</blockquote><blockquote>const { Agora } = NativeModules; //Define Agora object as a native module</blockquote><blockquote>const {</blockquote><blockquote>FPS30,</blockquote><blockquote>AudioProfileDefault,</blockquote><blockquote>AudioScenarioDefault,</blockquote><blockquote>Adaptative,</blockquote><blockquote>} = Agora; //Set defaults for Stream</blockquote><blockquote>class Video extends Component {</blockquote><blockquote>constructor(props) {</blockquote><blockquote>super(props);</blockquote><blockquote>this.state = {</blockquote><blockquote>peerIds: [], //Array for storing connected peers</blockquote><blockquote>uid: Math.floor(Math.random() * 100), //Generate a UID for local user</blockquote><blockquote>appid: this.props.AppID, //Enter the App ID generated from the Agora Website</blockquote><blockquote>channelName: this.props.ChannelName, //Channel Name for the current session</blockquote><blockquote>vidMute: false, //State variable for Video Mute</blockquote><blockquote>audMute: false, //State variable for Audio Mute</blockquote><blockquote>joinSucceed: false, //State variable for storing success</blockquote><blockquote>};</blockquote><blockquote>if (Platform.OS === ‘android’) {</blockquote><blockquote>const config = { //Setting config of the app</blockquote><blockquote>appid: this.state.appid, //App ID</blockquote><blockquote>channelProfile: 0, //Set channel profile as 0 for RTC</blockquote><blockquote>videoEncoderConfig: { //Set Video feed encoder settings</blockquote><blockquote>width: 720,</blockquote><blockquote>height: 1080,</blockquote><blockquote>bitrate: 1,</blockquote><blockquote>frameRate: FPS30,</blockquote><blockquote>orientationMode: Adaptative,</blockquote><blockquote>},</blockquote><blockquote>audioProfile: AudioProfileDefault,</blockquote><blockquote>audioScenario: AudioScenarioDefault,</blockquote><blockquote>};</blockquote><blockquote>RtcEngine.init(config); //Initialize the RTC engine</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>componentDidMount() {</blockquote><blockquote>RtcEngine.on(‘userJoined’, (data) =&gt; {</blockquote><blockquote>const { peerIds } = this.state; //Get currrent peer IDs</blockquote><blockquote>if (peerIds.indexOf(data.uid) === -1) { //If new user has joined</blockquote><blockquote>this.setState({</blockquote><blockquote>peerIds: […peerIds, data.uid], //add peer ID to state array</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>RtcEngine.on(‘userOffline’, (data) =&gt; { //If user leaves</blockquote><blockquote>this.setState({</blockquote><blockquote>peerIds: this.state.peerIds.filter(uid =&gt; uid !== data.uid), //remove peer ID from state array</blockquote><blockquote>});</blockquote><blockquote>});</blockquote><blockquote>RtcEngine.on(‘joinChannelSuccess’, (data) =&gt; { //If Local user joins RTC channel</blockquote><blockquote>RtcEngine.startPreview(); //Start RTC preview</blockquote><blockquote>this.setState({</blockquote><blockquote>joinSucceed: true, //Set state variable to true</blockquote><blockquote>});</blockquote><blockquote>});</blockquote><blockquote>RtcEngine.joinChannel(this.state.channelName, this.state.uid); //Join Channel</blockquote><blockquote>RtcEngine.enableAudio(); //Enable the audio</blockquote><blockquote>}</blockquote><p>We write the import statements and define the Agora object as native module and set the defaults.</p><p>We define the class based video component. In the constructor, we set state variables, array of connected peers, and local user’s unique id, agora app id, channelName, vidMute (True to mute local user’s video, False otherwise), and audMute for audio.</p><p>Now we set up video stream configuration in const config and initialize the RTC engine, by calling RtcEngine.init(config).</p><p>We define functions to execute user events before we bring together the components,,i.e. when a new user joins the call, we add their uid to the array; when user leaves the call, we remove their uid from the array; if the local users successfully joins the call channel, we start the stream preview.</p><p>…</p><blockquote>toggleAudio = () =&gt; {</blockquote><blockquote>let mute = this.state.audMute;</blockquote><blockquote>console.log(‘Audio toggle’, mute);</blockquote><blockquote>RtcEngine.muteLocalAudioStream(!mute);</blockquote><blockquote>this.setState({</blockquote><blockquote>audMute: !mute,</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>toggleVideo = () =&gt; {</blockquote><blockquote>let mute = this.state.vidMute;</blockquote><blockquote>console.log(‘Video toggle’, mute);</blockquote><blockquote>this.setState({</blockquote><blockquote>vidMute: !mute,</blockquote><blockquote>});</blockquote><blockquote>RtcEngine.muteLocalVideoStream(!this.state.vidMute);</blockquote><blockquote>}</blockquote><blockquote>endCall() {</blockquote><blockquote>RtcEngine.destroy();</blockquote><blockquote>Actions.home();</blockquote><blockquote>}</blockquote><p>Now we define the function to toggle the video and audio feeds of the user and end the call by leaving the channel.</p><p>…</p><blockquote>videoView() {</blockquote><blockquote>return (</blockquote><blockquote>&lt;View style={{ flex: 1 }}&gt;</blockquote><blockquote>{</blockquote><blockquote>this.state.peerIds.length &gt; 3. //view for four videostreams</blockquote><blockquote>? &lt;View style={{ flex: 1 }}&gt;</blockquote><blockquote>&lt;View style={{ flex: 1 / 2, flexDirection: ‘row’ }}&gt;&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[0]}</blockquote><blockquote>mode={1} /&gt;</blockquote><blockquote>&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[1]}</blockquote><blockquote>mode={1} /&gt;&lt;/View&gt;</blockquote><blockquote>&lt;View style={{ flex: 1 / 2, flexDirection: ‘row’ }}&gt;&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[2]}</blockquote><blockquote>mode={1} /&gt;</blockquote><blockquote>&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[3]}</blockquote><blockquote>mode={1} /&gt;&lt;/View&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>: this.state.peerIds.length &gt; 2. //view for three videostreams</blockquote><blockquote>? &lt;View style={{ flex: 1 }}&gt;</blockquote><blockquote>&lt;View style={{ flex: 1 / 2 }}&gt;&lt;AgoraView style={{ flex: 1 }}</blockquote><blockquote>remoteUid={this.state.peerIds[0]}</blockquote><blockquote>mode={1} /&gt;&lt;/View&gt;</blockquote><blockquote>&lt;View style={{ flex: 1 / 2, flexDirection: ‘row’ }}&gt;&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[1]}</blockquote><blockquote>mode={1} /&gt;</blockquote><blockquote>&lt;AgoraView style={{ flex: 1 / 2 }}</blockquote><blockquote>remoteUid={this.state.peerIds[2]}</blockquote><blockquote>mode={1} /&gt;&lt;/View&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>: this.state.peerIds.length &gt; 1. //view for two videostreams</blockquote><blockquote>? &lt;View style={{ flex: 1 }}&gt;&lt;AgoraView style={{ flex: 1 }}</blockquote><blockquote>remoteUid={this.state.peerIds[0]}</blockquote><blockquote>mode={1} /&gt;&lt;AgoraView style={{ flex: 1 }}</blockquote><blockquote>remoteUid={this.state.peerIds[1]}</blockquote><blockquote>mode={1} /&gt;&lt;/View&gt;</blockquote><blockquote>: this.state.peerIds.length &gt; 0. //view for videostream</blockquote><blockquote>? &lt;AgoraView style={{ flex: 1 }}</blockquote><blockquote>remoteUid={this.state.peerIds[0]}</blockquote><blockquote>mode={1} /&gt;</blockquote><blockquote>: &lt;View /&gt;</blockquote><blockquote>}</blockquote><blockquote>{</blockquote><blockquote>!this.state.vidMute. //view for local video</blockquote><blockquote>? &lt;AgoraView style={styles.localVideoStyle} zOrderMediaOverlay={true} showLocalVideo={true} mode={1} /&gt;</blockquote><blockquote>. &lt;View /&gt;</blockquote><blockquote>}</blockquote><blockquote>&lt;View style={styles.buttonBar}&gt;</blockquote><blockquote>&lt;Icon.Button style={styles.iconStyle}</blockquote><blockquote>backgroundColor=”#0093E9&quot;</blockquote><blockquote>name={this.state.audMute ? ‘mic-off’ : ‘mic’} onPress={() =&gt; this.toggleAudio()}</blockquote><blockquote>/&gt;</blockquote><blockquote>&lt;Icon.Button style={styles.iconStyle}</blockquote><blockquote>backgroundColor=”#0093E9&quot;</blockquote><blockquote>name=”call-end”</blockquote><blockquote>onPress={() =&gt; this.endCall()}</blockquote><blockquote>/&gt;</blockquote><blockquote>&lt;Icon.Button style={styles.iconStyle}</blockquote><blockquote>backgroundColor=”#0093E9&quot;</blockquote><blockquote>name={this.state.vidMute ? ‘videocam-off’ : ‘videocam’}</blockquote><blockquote>onPress={() =&gt; this.toggleVideo()}</blockquote><blockquote>/&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>&lt;/View&gt;</blockquote><blockquote>);</blockquote><blockquote>}</blockquote><blockquote>render() {</blockquote><blockquote>return this.videoView();</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>const styles = StyleSheet.create({</blockquote><blockquote>buttonBar: {</blockquote><blockquote>height: 50,</blockquote><blockquote>backgroundColor: ‘#0093E9&#39;,</blockquote><blockquote>display: ‘flex’,</blockquote><blockquote>width: ‘100%’,</blockquote><blockquote>position: ‘absolute’,</blockquote><blockquote>bottom: 0,</blockquote><blockquote>left: 0,</blockquote><blockquote>flexDirection: ‘row’,</blockquote><blockquote>justifyContent: ‘center’,</blockquote><blockquote>alignContent: ‘center’,</blockquote><blockquote>},</blockquote><blockquote>localVideoStyle: {</blockquote><blockquote>width: 140,</blockquote><blockquote>height: 160,</blockquote><blockquote>position: ‘absolute’,</blockquote><blockquote>top: 5,</blockquote><blockquote>right: 5,</blockquote><blockquote>zIndex: 100,</blockquote><blockquote>},</blockquote><blockquote>iconStyle: {</blockquote><blockquote>fontSize: 34,</blockquote><blockquote>paddingTop: 15,</blockquote><blockquote>paddingLeft: 40,</blockquote><blockquote>paddingRight: 40,</blockquote><blockquote>paddingBottom: 15,</blockquote><blockquote>borderRadius: 0,</blockquote><blockquote>},</blockquote><blockquote>});</blockquote><blockquote>export default Video;</blockquote><p>Now we define the view of different possible number of users. We call this function inside render method. We define the styles for the internal components and export our component video to use with the router.</p><p>And that’s how the app works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24857590b5e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agora The New Face In Video Calling]]></title>
            <link>https://medium.com/@sanufaris5/agora-the-new-face-in-video-calling-112c9146a1c0?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/112c9146a1c0</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 16:10:09 GMT</pubDate>
            <atom:updated>2020-03-25T18:25:39.107Z</atom:updated>
            <content:encoded><![CDATA[<p>Agora has come up with the feature of video calling with great quality.</p><p>Agora provides a platform that allows the users in video calling which supports any devices and networks. This platform supports one-one video calling and group chatting. The developers of this app allows the users to connect with others anytime and from anywhere they want. This app provides the best video calling expiration for the users.</p><p>Agora.io supports a range of tech stacks making it easy to deliver deep integration of high-quality, extreme low-latency video calling across all platforms and channels. This app is supported in most of the platforms like Ios, android, Linux, Windows etc.</p><h3>Steps:</h3><ol><li>Create an account in <strong>Agora.io.</strong></li><li>Now login to your account and you will be redirected to dashboard page.</li><li>There goto <strong>Project&lt;Project</strong> List and copy your App ID.</li><li>Now download latest Agora Video SDK (<a href="https://docs.agora.io/en/Agora%20Platform/downloads">https://docs.agora.io/en/Agora%20Platform/downloads</a>)</li><li>Next step is to copy the <strong>AgoraRTCSDK-x.x.x..js</strong> file from the Agora-Web-SDK folder to the Videochat-web-agora/scripts folder.</li><li>Now open <strong>call.html</strong> page in an editor.</li><li>Open <strong>script.js</strong> file inside <em>videochat-web-agora/scripts</em> folder.</li><li>Replace <em>&lt;-Your App-ID Here&gt;</em> with your App-ID.</li><li>Open the <strong>index.html</strong> file in a browser.</li><li>A home page with a Join Button will appear in your browser. Just click on the Join button.</li><li>You will be prompted to give permission for video and microphone access. Click allow and wait for few seconds.</li></ol><p>That’s it. You’re done.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=112c9146a1c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agora The Future Of Voice Call]]></title>
            <link>https://medium.com/@sanufaris5/agora-the-future-of-voice-call-a6a275931ad9?source=rss-29aa33e3b062------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6a275931ad9</guid>
            <dc:creator><![CDATA[Sanufaris]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 14:00:40 GMT</pubDate>
            <atom:updated>2020-03-19T06:02:18.731Z</atom:updated>
            <content:encoded><![CDATA[<p>Agora is providing a voice calling platform which provides good audio quality for the users.</p><p>This platform supports voice calling in any network and in any devices like mobile phones and desktops. This platform supports one to one voice calling and group calls. The developers have made this platform useful for users to connect easily and clearly at any time and any where they want. Agora provides the best quality audio calling platform for the users.</p><p>Agora.io has become the global leader in real-time communication solutions. They have released a SDK known as “Agora React Native SDK” which is an open source developer toolset for adding voice call functionality to the apps using the React Native Framework.</p><p>Agora’s software-Defined Real-Time Network is a real time transmission network infrastructure designed for real time communication. This app deploys almost 200 data centers worldwide that use dynamic routing algorithms to achieve millisecond latency.</p><h4>Features Of Agora</h4><ul><li>Very easy to implement</li><li>Provides 3D surround sound experience</li><li>Optimize Anti-packet loss</li></ul><p>Let me show you guys an example of how to implement voice call feature in Agora in Android:</p><h4>Requirements</h4><ul><li>Android Studio 3.0 or later</li><li>Android SDK API Level 16 or higher</li><li>A mobile device with Android 4.1 or later</li><li>A valid Agora account</li></ul><h4>Steps:</h4><ol><li>Create an android project in Android Studio.</li><li>Integrate the Agora Voice SDK to your project.</li></ol><ul><li>To integrate the SDK, just add the following line /app/build.gradle file of the project.</li></ul><blockquote>…</blockquote><blockquote>dependencies {</blockquote><blockquote>…</blockquote><blockquote>// 3.0.0 is the latest version of the Agora Voice SDK. You can set it to other versions.</blockquote><blockquote>implementation ‘io.agora.rtc:voice-sdk:2.9.4&#39;</blockquote><blockquote>}</blockquote><p>3. Now you must add project permissions for device access according to your needs.</p><ul><li>Add the following permissions to <strong>/app/src/main/AndroidManifest.xml</strong></li></ul><blockquote>&lt;manifest xmlns:android=”http://schemas.android.com/apk/res/android”</blockquote><blockquote>package=”io.agora.tutorials1v1acall”&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.READ_PHONE_STATE” /&gt;.</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.INTERNET” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.RECORD_AUDIO” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.BLUETOOTH” /&gt;</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” /&gt;</blockquote><blockquote>// Add the following permission if your scenario involves reading the external storage:</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE” /&gt;</blockquote><blockquote>// For devices running Android 10.0 or later, you also need to add the following permission:</blockquote><blockquote>&lt;uses-permission android:name=”android.permission.READ_PRIVILEGED_PHONE_STATE” /&gt;</blockquote><blockquote>…</blockquote><blockquote>&lt;/manifest&gt;</blockquote><p><strong>Implementing the basic voice call</strong></p><ol><li>Create the user interface (UI) for one-to-one voice call in the layout of your project.</li><li>Now import the following classes in the activity file of your project:</li></ol><blockquote>import io.agora.rtc.IRtcEngineEventHandler;</blockquote><blockquote>import io.agora.rtc.RtcEngine;</blockquote><p>3. Next step is to call the <strong><em>checkSelfPermission</em></strong> method to access the microphone of the Android device.</p><blockquote>private static final int PERMISSION_REQ_ID_RECORD_AUDIO = 22;</blockquote><blockquote>// Check the microphone access when running the app.</blockquote><blockquote>@Override</blockquote><blockquote>protected void onCreate(Bundle savedInstanceState) {</blockquote><blockquote>super.onCreate(savedInstanceState);</blockquote><blockquote>setContentView(R.layout.activity_voice_chat_view);</blockquote><blockquote>// Initialize RtcEngine after getting the permission.</blockquote><blockquote>if (checkSelfPermission(Manifest.permission.RECORD_AUDIO, PERMISSION_REQ_ID_RECORD_AUDIO)) {</blockquote><blockquote>initAgoraEngineAndJoinChannel();</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>private void initAgoraEngineAndJoinChannel() {</blockquote><blockquote>initializeAgoraEngine();</blockquote><blockquote>joinChannel();</blockquote><blockquote>}</blockquote><blockquote>public boolean checkSelfPermission(String permission, int requestCode) {</blockquote><blockquote>Log.i(LOG_TAG, “checkSelfPermission “ + permission + “ “ + requestCode);</blockquote><blockquote>if (ContextCompat.checkSelfPermission(this,</blockquote><blockquote>permission)</blockquote><blockquote>!= PackageManager.PERMISSION_GRANTED) {</blockquote><blockquote>ActivityCompat.requestPermissions(this,new String[]</blockquote><blockquote>{permission},</blockquote><blockquote>requestCode);</blockquote><blockquote>return false;</blockquote><blockquote>}</blockquote><blockquote>return true;</blockquote><blockquote>}</blockquote><p>4. Initializing RtcEngine</p><ul><li>Go to Console and click the Project Management icon.</li><li>Click Create and set the project name, choose an authentication mechanism, and Click Submit.</li><li>On the Project Management page, find the App ID of your project.</li><li>Call the create method and pass in the App ID to initialize the RtcEngine object.</li></ul><blockquote>private RtcEngine mRtcEngine;</blockquote><blockquote>private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {</blockquote><blockquote>// Listen for the onUserOffline callback.</blockquote><blockquote>// This callback occurs when the remote user leave the channel or drops offline.</blockquote><blockquote>@Override</blockquote><blockquote>public void onUserOffline(final int uid, final int reason) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>onRemoteUserLeft(uid, reason);</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>// Listen for the onUserMuterAudio callback.</blockquote><blockquote>// This callback occurs when a remote user stops sending the audio stream.</blockquote><blockquote>@Override</blockquote><blockquote>public void onUserMuteAudio(final int uid, final boolean muted) {</blockquote><blockquote>runOnUiThread(new Runnable() {</blockquote><blockquote>@Override</blockquote><blockquote>public void run() {</blockquote><blockquote>onRemoteUserVoiceMuted(uid, muted);</blockquote><blockquote>}</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>};</blockquote><p>…</p><blockquote>// Call the create method to initialize RtcEngine.</blockquote><blockquote>private void initializeAgoraEngine() {</blockquote><blockquote>try {</blockquote><blockquote>mRtcEngine = RtcEngine.create(getBaseContext(), getString(R.string.agora_app_id), mRtcEventHandler);</blockquote><blockquote>mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);</blockquote><blockquote>} catch (Exception e) {</blockquote><blockquote>Log.e(LOG_TAG, Log.getStackTraceString(e));</blockquote><blockquote>throw new RuntimeException(“NEED TO check rtc sdk init fatal error\n” + Log.getStackTraceString(e));</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>5. After initializing the RtcEngine, can call the <strong>joinChannel</strong> method to join a channel. In this method, set the following parameters:</p><blockquote>private void joinChannel() {</blockquote><blockquote>String accessToken = getString(R.string.agora_access_token);</blockquote><blockquote>if (TextUtils.equals(accessToken, “”) || TextUtils.equals(accessToken, “#YOUR ACCESS TOKEN#”)) {</blockquote><blockquote>accessToken = null; // default, no token</blockquote><blockquote>}</blockquote><blockquote>mRtcEngine.joinChannel(accessToken, “voiceDemoChannel1&quot;, “Extra Optional Data”, 0); // The uid is not specified. The SDK will assign one automatically.</blockquote><blockquote>}</blockquote><p>6. Call the <strong>leaveChannel</strong> method to leave the current call.</p><blockquote>private void leaveChannel() {</blockquote><blockquote>mRtcEngine.leaveChannel();</blockquote><blockquote>}</blockquote><p>7. Run the project on your Android device. That’s it. Now you can hear the remote user when you start a one-to-one voice call in the app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6a275931ad9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>