IOS SDK Introduction
The ring-letter SDK provides a complete set of development frameworks for users to develop IM-related applications. Includes the following sections:
- Sdk_core: For the core of the message Synchronization protocol implementation, to complete the exchange of information with the server.
- SDK: is based on the core protocol implementation of the complete IM capabilities, the implementation of different types of messaging, session management, groups, friends, chat rooms and other functions.
- Easeui: is a set of IM-related UI controls designed to help developers quickly integrate the ring-letter SDK.
Users can implement their own applications based on the demos we provide, or they can develop their own applications based on the SDK.
The SDK adopts modular design, each module function is relatively independent and perfect, the user can choose to use the following modules according to their own needs:
- Emclient: Is the entry of the SDK, the main completion of login, exit, connection management and other functions. Access to other modules is also available.
- Emchatmanager: Manage the delivery of messages, complete session management and other functions.
- Emcontactmanager: Responsible for the addition and deletion of friends, blacklist management.
- Emgroupmanager: Responsible for group management, create, delete groups, manage group members and other functions.
- Emchatroommanager: Responsible for the management of the chat room.
Note: If you are upgrading from sdk2.x to 3.0, you can refer to the ring letter SDK 2.x to 3.0 upgrade documentation
Introduction to the third party libraries
Third-party libraries used in Easeui:
- Mwphotobrowser: Image processing Library, browsing display
- Mjrefresh: For page refresh
- Mbprogresshud: Used to prompt for load refresh
- LIBOPENCORE-AMRNB.A,LIBOPENCORE-AMRWB.A: For conversion between AMR and WAV
Third-party libraries used in the Demo:
- The user information in parse.framework and Bolts.framework:Demo is stored in parse, which is the library required for parse, and if the developer does not use the parse store, do not copy it into your project
- LIBMOBCLICKLIBRARY.A: Friends of the relevant library, for the ring of the basic information of the DEMO statistics, developers do not need or have other versions of the library do not copy to their own projects
Configure the Project import SDK
Drag the Downloaded SDK folder (HYPHENATESDK) into the project and tick the Destination.
Set project Properties
1th step: Add the dependent libraries to the build Phases→link Binary with Libraries.
The SDK dependent libraries are:
- Coremedia.framework
- Audiotoolbox.framework
- Avfoundation.framework
- Mobilecoreservices.framework
- Imageio.framework
- Libc++.dylib
- Libz.dylib
- Libstdc++.6.0.9.dylib
- Libsqlite3.dylib
(If you are using Xcode7, the suffix is TBD.) )
The SDK includes a real-time voice dependent library:
- Coremedia.framework
- Audiotoolbox.framework
- Avfoundation.framework
- Mobilecoreservices.framework
- Imageio.framework
- Libc++.dylib
- Libz.dylib
- Libstdc++.6.0.9.dylib
- Libsqlite3.dylib
- Libiconv.dylib
(If you are using Xcode7, the suffix is TBD.) )
2nd step: SDK does not support Bitcode, set no in Build settings→linking→enable Bitcode.
Compiling the project
After the above steps are finished, compile the project. If there is no error, congratulations, the integration SDK is successful, you can proceed to the next step.
Initializing the SDK
1th step: Introduce the relevant header file #import "EMSDK.h".
2nd step: In the appdelegate of the project, call the SDK corresponding method in the following method.
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions2 {3 //AppKey: Registered AppKey, see the following notes in detail. 4 //Apnscertname: The title of the Push card (no suffix required), see the following notes in detail. 5Emoptions *options = [emoptions optionswithappkey:@"Douser#istore"];6Options.apnscertname =@"Istore_dev";7 [[Emclient sharedclient] initializesdkwithoptions:options];8 9 returnYES;Ten } One A //app goes backstage -- (void) Applicationdidenterbackground: (UIApplication *) Application - { the [[Emclient sharedclient] applicationdidenterbackground:application]; - } - - //the app will return from the background +- (void) Applicationwillenterforeground: (UIApplication *) Application - { + [[Emclient sharedclient] applicationwillenterforeground:application]; A}
The SDK interface parameters that are called are interpreted as follows:
- AppKey: Differentiate the APP's logo, refer to the developer registration and management background.
- Apnscertname:ios the name of the push certificate, refer to make and upload the push certificate.
Ring Letter for IM section provides APNS push function, if you want to use, please jump to APNS offline push.
Registered
Registration mode is divided into two types, open registration and authorized registration.
- Client registration is only possible if the registration is open. Open registration is for testing purposes, and it is not recommended to use this method to register a ring account in a formal environment.
- The process of authorizing registration should be the REST API that your server provides through the ring, which is then saved to your server or returned to the client.
1 #import "RegistViewController.h"2 #import "EMSDK.h" //the framework of the ring letter3 @interfaceRegistviewcontroller ()4 //User name5@property (Weak, nonatomic) Iboutlet Uitextfield *usernametextfiled;6 7 //Password8@property (Weak, nonatomic) Iboutlet Uitextfield *Passwordtextfield;9 Ten One @end A - @implementationRegistviewcontroller - the- (void) Viewdidload { - [Super Viewdidload]; - //Do any additional setup after loading the view. - } + - //Click the Register button +-(Ibaction) Didclickregistbutton: (ID) Sender { A at if(Self.userNameTextFiled.text.length = =0|| Self.passwordTextField.text.length = =0) { -NSLog (@"User name password cannot be empty"); - return; - } - - //How to register a ring letter in -Emerror *error =[[emclient sharedclient] registerWithUsername:self.userNameTextFiled.text Password: Self.passwordTextField.text]; toNSLog (@"error =%@", error); + if(!error) { -NSLog (@"Registration Successful"); the } * $}
Login
Login: Invokes the operation of the SDK's login interface.
1 #import "ViewController.h"2 #import "EMSDK.h"3 @interfaceViewcontroller ()4 //User name5@property (Weak, nonatomic) Iboutlet Uitextfield *Usernamefiledtext;6 7 //Password8@property (Weak, nonatomic) Iboutlet Uitextfield *Passwordfieldtext;9 Ten One @end A - @implementationViewcontroller - the- (void) Viewdidload { - [Super Viewdidload]; - //additional setup after loading the view, typically from a nib. - } + - + //Login Button A-(Ibaction) Loginclickbutton: (ID) Sender { at - if(self.) UserNameFiledText.text.length = =0|| Self.passwordFieldText.text.length = =0) { -NSLog (@"User name password cannot be empty"); - } - - //how to sign in with ring letter inEmerror *error =[[Emclient sharedclient] loginwithusername:self. Usernamefiledtext.text Password:self.passwordFieldText.text]; -NSLog (@"%@", error); to if(!error) { +NSLog (@"Login Successful"); - //return to the session list the * [self dismissviewcontrolleranimated:yes completion:nil]; $ }Panax Notoginseng -}
Automatic Login
Automatic login: After the first login is successful, you do not need to call the login method again, and the SDK will log you in automatically the next time the APP launches. And if you fail to log on automatically, you can also read the previous session information.
The automatic login property in the SDK is turned off by default and requires that you set it after the login is successful, so that you don't need to call the ring login again the next time the APP starts, and you can get a list of sessions without a network.
1 emerror *error = [[Emclient sharedclient] Loginwithusername:@ "8001" Password: @" 111111 " ]; 2 if (! error) 3 {4 [[Emclient sharedclient].options setisautologin:yes]; 5 }
Introduction and import of IOS SDK