Li Hongqiang iOS Development-02.1_ ring letter SDK 2.x to 3.0 upgrade documentation

Source: Internet
Author: User

Li Hongqiang iOS Development-02.1_ Ring Letter SDK 2.x to 3.0 Upgrade Documentation SDK 2.x to 3.0 Upgrade Guide Ring Letter SDK 3.0 Upgrade Documentation

The core class in 3.0 is the Emclient class, which can be obtained through the Emclient class to Chatmanager, Groupmanager, Contactmanager, and Roommanager objects. The original 2.0 version of the SDK many methods provide synchronous, asynchronous callback, asynchronous (block) three methods, version 3.0 only provides a synchronous method (Async method is the beginning of async methods).

For example:

2.0 version of the login method, provides synchronous, asynchronous, asynchronous block three methods-(nsdictionary *) Loginwithusername:(NSString *) Username password:(NSString *) Password error:(Emerror**) perror;-(void) Asyncloginwithusername:(NSString *) Username password:(NSString *) password;-(void) Asyncloginwithusername:(NSString *) Username password:(NSString * password Completion: (void  (^)  (nsdictionary  *logininfo, Emerror *error) ) completion Onqueue: (Dispatch_queue_t 3.0 version, the method of network request only provides synchronization method - (emerror *) Loginwithusername: (nsstring  *< Span class= "Br0" >) ausername Password: (nsstring  *            

Registering callbacks, the 3.0 SDK has modularized functionality, encapsulating different function callbacks into different modules.

2.0 Version Callback Registration[[Easemob sharedinstance].chatmanager AddDelegate: Self delegatequeue:Nil];3.0 Version Callback registration requires sub-module registration[[Emclient sharedclient] AddDelegate: Self delegatequeue:Nil];Login-related callbacks[[Emclient sharedclient].groupmanager AddDelegate:self delegatequeue:nil]; Group callback [[emclient sharedclient].contactmanager adddelegate< Span class= "sy0" >:self delegatequeue:nil]; Contact callback [[emclient sharedclient].roommanager adddelegate< Span class= "sy0" >:self delegatequeue:nil]; Chat Room callback [[emclient sharedclient].chatmanager adddelegate< Span class= "sy0" >:self delegatequeue:nil]; Message callback                
Using the upgrade replacement script

3.0 Upgrading AIDS (replacing enumerations, attributes, method names, and so on):

Python emreplace.py Replacepath

Xcode Compile prompt tool:

1. Xcode->build PHASES//2. Add a new run SCRIPT//3. Fill in script: Python ${path}/emchecker.py//compile run will prompt
Code upgrade Replacement Document

3.0 SDK Most of the code compared to the 2.0 SDK, the logic does not change, in order to uniformly modify the name. The 2.0 version provides asynchronous methods, and the corresponding callback 3.0 is no longer supported (note: 3 only provides synchronous methods).

Change of entrance, version 2.0 [easemob shareinstance]→3.0 version [Emclient sharedclient].

version 2.0 version 3.0
Login related
Version 2.0, currently logged in user information
[[[Easemob sharedinstance] chatmanager] Logininfo]
version 3.0, only current login account is available
[[Emclient sharedclient] currentusername]
Version 2.0, whether the user currently has a login
[[[Easemob sharedinstance] chatmanager] isLoggedIn]
version 3.0
[[Emclient sharedclient] isLoggedIn]
Version 2.0, whether to connect to chat server
[[[Easemob sharedinstance] chatmanager] isconnected]
version 3.0
[[Emclient sharedclient] isconnected]
Version 2.0, importing database data into a new database
[[Easemob Sharedinstance].chatmanager Importdatatonewdatabase]
version 3.0, upgrading to the SDK version 3.0 needs to call this method, developers need to wait for the method after the execution of the database query operation
[[Emclient sharedclient] DataMigrationTo3]
Version 2.0, obtaining information from the database
[[Easemob Sharedinstance].chatmanager Loaddatafromdatabase]
version 3.0 is no longer supported
version 2.0, create an account on Chat server
-(BOOL) Registernewaccount: (NSString *) Username password: (nsstring *) Password error: ( Emerror * *) perror;
-(void) Asyncregisternewaccount: (NSString *) Username password: (nsstring *) password;
-(void) Asyncregisternewaccount: (NSString *) Username password: (nsstring *) password withcompletion: (void (^) ( NSString *username,nsstring *password,emerror *error)) Completion onqueue: (dispatch_queue_t) aQueue;
version 3.0, only the synchronization method is available
Emerror *error = [[emclient sharedclient] registerwithusername:@ "username" password:@ "password" ]
version 2.0, login to chat server using username password
-(nsdictionary *) Loginwithusername: (NSString *) Username password: (NSString *) Password Error: (Emerror *) perror
-(void) Asyncloginwithusername: (NSString *) Username password: (NSString *) Password
-(void) Asyncloginwithusername: (NSString *) Username password: (nsstring *) password completion: (void (^) ( Nsdictionary *logininfo, Emerror *error)) Completion onqueue: (dispatch_queue_t) Aqueue
3.0 version, only provides synchronous method
-( Emerror *) Loginwithusername: (NSString *) ausername Password: (NSString *) Apassword
//Call method: Emerror *error = [[ Emclient sharedclient] loginwithusername:@ "username" password:@ "password"]
Version 2.0, log off the currently logged on user
-(Nsdictionary *) Logoffwithunbinddevicetoken: (BOOL) Isunbind error: (Emerror *) perror;
-(void) Asynclogoffwithunbinddevicetoken: (BOOL) Isunbind;
-(void) Asynclogoffwithunbinddevicetoken: (BOOL) Isunbind completion: (void (^) (nsdictionary *info, Emerror *error)) Completion onqueue: (dispatch_queue_t) Aqueue;
version 3.0, only synchronization methods are available
-(Emerror *) Logout: (BOOL) Bisunbinddevicetoken;
Calling method: Emerror *error = [[Emclient sharedclient] logout:no];
Login Callback
2.0 version->emchatmanagerlogindelegate 3.0 Version->emclientdelegate
Callback for the user to perform an automatic logon operation
-(void) Willautologinwithinfo: (nsdictionary *) Logininfo Error: (EMERROR *) error;
Callback after the user logs on
-(void) Didloginwithinfo: (nsdictionary *) Logininfo Error: (EMERROR *) error;
Callback after the user logs off
-(void) Didlogoffwitherror: (Emerror *) error;
Callback after registering a new user
-(void) Didregisternewaccount: (NSString *) Username password: (nsstring *) password error: (EMERROR *) error;
callbacks that are no longer supported by version 3.0
2.0 version, callback after user auto login completed
-(void) Didautologinwithinfo: (nsdictionary *) Logininfo Error: (EMERROR *) error;
version 3.0 use Emclientdelegate
-(void) Didautologinwitherror: (Emerror *) error;
2.0 version, notification callback for current login when other device is logged in
-(void) didloginfromotherdevice;
2.0 version, the current login account has been removed from the server side
-(void) didremovedfromserver;
version 3.0 uses Emclientdelegate, and callback behavior is consistent with 2.0
Version 2.0, the callback that will initiate the automatic re-connect operation
-(void) willautoreconnect;
Callback after the automatic re-connect operation is completed
-(void) Didautoreconnectfinishedwitherror: (Nserror *) error;
version 3.0 use Emclientdelegate
-(void) didconnectionstatechanged: (emconnectionstate) ConnectionState;
Message-related
2.0 version Ichatmanagerchat 3.0 Version Iemchatmanager
version 2.0, method of sending message
-(Emmessage *) SendMessage: (Emmessage *) message progress: (ID) Progress error: (Emerror *) perror;
-(Emmessage *) Asyncsendmessage: (Emmessage *) message progress: (ID) Progress;
-(Emmessage *) Asyncsendmessage: (Emmessage *) message progress: (ID) Progress prepare: (void (^) (Emmessage *message, Emerror *error) Prepare Onqueue: (dispatch_queue_t) Apreparequeue completion: (void (^) (emmessage *message, EMError * Error)) Completion Onqueue: (dispatch_queue_t) acompletionqueue;
3.0 version
-(void) Asyncsendmessage: (Emmessage *) amessage Progress: (void (^) (int progress)) Aprogress completion: ( void (^) (emmessage *message, Emerror *error)) aprogresscompletion;
//Call://[[emclient sharedclient].chatmanager asyncsendmessage:message progress:nil completion:^ (EMMessage * Amessage, Emerror *aerror) {}];
version 2.0, which sends a "read message" (which is displayed on the UI or sent at the time of the burned-out destruction) to the server
-(void) Sendreadackformessage: (emmessage *) message;
3.0 version
-(void) Asyncsendreadackformessage: (emmessage *) message;
//Call://[[emclient Sharedclient].chatmanager asyncsendreadackformessage:message];
Version 2.0, resend a message
-(Emmessage *) Resendmessage: (Emmessage *) message progress: (ID) Progress error: (Emerror *) perror;
-(Emmessage *) Asyncresendmessage: (Emmessage *) message progress: (ID) Progress;
-(Emmessage *) Asyncresendmessage: (Emmessage *) message progress: (ID) Progress prepare: (void (^) (Emmessage *message, Emerror *error) Prepare Onqueue: (dispatch_queue_t) Apreparequeue completion: (void (^) (emmessage *message, EMError * Error)) Completion Onqueue: (dispatch_queue_t) acompletionqueue;
version 3.0
*/-(void) Asyncresendmessage: (Emmessage *) amessage Progress: (void (^) (int progress)) Aprogresscompletion completion: ( void (^) (emmessage *message, Emerror *error)) acompletion;
Call://[[emclient sharedclient].chatmanager asyncresendmessage:message progress:nil completion:^ (EMMessage * Amessage, Emerror *aerror) {}];
Chat Room Related
version 2.0 version 3.0
2.0 version, chat room theme
@property (Nonatomic, Strong, ReadOnly) NSString *chatroomsubject;
version 3.0
@property (nonatomic, copy, readonly) NSString *subject;
2.0 version, description of the chat room
@property (Nonatomic, Strong, ReadOnly) NSString *chatroomdescription;
version 3.0
@property (nonatomic, copy, readonly) NSString *description;
2.0 version, maximum number of chat rooms
@property (nonatomic, readonly) Nsinteger Chatroommaxoccupantscount;
version 3.0
@property (nonatomic, readonly) Nsinteger Maxoccupantscount;
Group-related
version 2.0 version 3.0
Version 2.0, get the group associated with the login from the database
-(Nsarray *) Loadallmygroupsfromdatabasewithappend2chat: (BOOL) append2chat;
version 3.0
-(Nsarray *) Loadallmygroupsfromdb;
Call: [[Emclient Sharedclient].groupmanager Loadallmygroupsfromdb];
version 2.0, create a group
-(Emgroup *) Creategroupwithsubject: (NSString *) Subject Description: (NSString *) description Invitees: (Nsarray *) invitees Initialwelcomemessage: (NSString *) welcomemessage stylesetting: (EMGroupStyleSetting *) Stylesetting Error: (emerror * *) perror;
-(void) Asynccreategroupwithsubject: (NSString *) Subject Description: (NSString *) description invitees: (Nsarray *) Invitees Initialwelcomemessage: (NSString *) welcomemessage stylesetting: (emgroupstylesetting *) styleSetting;
-(void) Asynccreategroupwithsubject: (NSString *) Subject Description: (NSString *) description invitees: (Nsarray *) Invitees Initialwelcomemessage: (NSString *) welcomemessage stylesetting: (emgroupstylesetting *) styleSetting Completion: (void (^) (Emgroup *group, Emerror *error)) Completion onqueue: (dispatch_queue_t) Aqueue;
Version 3.0
-(Emgroup *) Creategroupwithsubject: (NSString *) asubject Description: (NSString *) adescription invitees: (Nsarray *) Ainvitees message: (NSString *) amessage setting: (emgroupoptions *) asetting Error: (Emerror *) perror;
Call://emerror *error = nil; Emgroup *group = [[Emclient sharedclient].groupmanager creategroupwithsubject:@ "subject" description:@ "desc" Invitees:source message:@ "message" Setting:setting error:&error];
2.0 versions, creating anonymous groups version 3.0 is no longer available
version 2.0, join an anonymous public group version 3.0 is no longer available
version 2.0, exit the group (requires non-owner permissions)
-(Emgroup *) Leavegroup: (NSString *) groupId Error: (Emerror *) perror;
-(void) Asyncleavegroup: (NSString *) groupId;
-(void) Asyncleavegroup: (NSString *) groupId Completion: (void (^) (Emgroup *group, Emgroupleavereason reason, Emerror *error)) Completion onqueue: (dispatch_queue_t) Aqueue;
3.0 Version
-(Emgroup *) Leavegroup: (NSString *) Agroupid Error: (Emerror *) perror;
//Call://emerror *error = nil,//[[emclient sharedclient].groupmanager leavegroup:@ "GroupId" error:&error];
2.0 version, dissolve group, need owner permission
-(Emgroup *) Destroygroup: (NSString *) groupId Error: (Emerror *) perror;
-(void) Asyncdestroygroup: (NSString *) groupId;
-(void) Asyncdestroygroup: (NSString *) groupId Completion: (void (^) (Emgroup *group, Emgroupleavereason reason, Emerror * Error)) Completion Onqueue: (dispatch_queue_t) Aqueue;
version 3.0
-(Emgroup *) Destroygroup: (NSString *) Agroupid Error: (Emerror *) perror;
Call://emerror *error = nil; [[Emclient Sharedclient].groupmanager destroygroup:@ "GroupId" error:&error];

Li Hongqiang iOS Development-02.1_ ring letter SDK 2.x to 3.0 upgrade documentation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.