Gobelieve IOS SDK Access Memo

Source: Internet
Author: User

Project configuration
    • In the project target "Build Settings", find "linking" of "other Linker Flags", add parameters -ObjC .
Imsdk
    • IMSDK contains only message basic communication functions
Initialize IM

To start the IM service, you only need to set the user's access token, invoke the Start interface, and add a listener to the message.

[Imservice Instance].deviceid = [[[Uidevice Currentdevice] Identifierforvendor] uuidstring];[ [Imservice instance] startrechabilitynotifier];
When the user logs on successfully, start IM, set the user's accesstoken and start IM
[Imhttpapi Instance].accesstoken == accesstoken;[ [Imservice instance] start];
Clears user's devicetoken and stops im when user logs off
@"" [[Imservice instance] stop];
Apply cut-to-background pause IM, after which all messages will be sent through the push channel
[[Imservice instance] enterbackground];
Apply cut-to-foreground recovery IM
[[Imservice instance] enterforeground];
Send Message
    • Starting the IM service sets the user ID to start sending messages, and the code sent by the message needs to be called in the UI thread (the message content size is limited to 4k):

        Immessage *im = [[Immessage alloc] init];   // set Sender ID  Im.sender = sender;   // set receiver ID  Im.receiver = receiver;   // message local ID  Im.msglocalid = msglocalid;   " Message Content " ;  [[Imservice instance] Sendpeermessage:im];
Class Imservice to set the current user's access token
属性名:String accessToken功能:在调用start之前必须要设置用户的accessToken,token是由第三方应用服务器调用IM服务器RestAPI所得。
Set the ID of the current device
属性名:String deviceID功能:设备id可以用户多点登陆的唯一性判断,可选调用
Set Observer
方法名: -(void) addMessageObserver:(id<IMServiceObserver>)observer功能:设置observer,在observer中处理接受到的消息。参数说明: * observer 观察者返回值:无返回值
Start accepting messages
方法名:-(void) start功能:用户登陆成功后,连接im服务器来接受在线消息。
Stop accepting messages
方法名:-(void) stop功能:用户注销后,断开和im服务器的连接,从而终止接受在线消息。
App enters the foreground
方法名:-(void) enterForeground功能:应用进入前台,im服务器将停止将消息推送到通知栏
App goes into the background
方法名:-(void) enterBackground功能:应用进入后台,im服务器会将将消息推送到通知栏
Send Message
方法名: -(BOOL) sendPeerMessage:(IMMessage*)msg功能:发送im消息,如果当前连接处于断开状态,消息会发送失败, 函数返回YES,也不能表明服务器已经接收到消息。参数说明: *msg 消息对象返回值:BOOL
Interface Imserviceobserver Connection Status
方法名:-(void) onConnectState:(int)state功能:连接状态变更通知参数说明: *state 连接的状态 STATE_UNCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_CONNECTFAIL返回值:无返回值
Remote Login
方法名: -(void) onLoginPoint:(LoginPoint*)lp功能:当前登陆用户在异地登陆参数说明: *lp 登录点信息返回值:无返回值
News
方法名:-(void) onPeerMessage:(IMMessage*)msg功能:接受到一条im消息参数说明: *msg 消息对象返回值:无返回值
Message ack
方法名:-(void) onPeerMessageACK:(int)msgLocalID uid:(int64_t)uid功能:服务器对收到消息的ack,此时这条消息才能标志为发送成功参数说明: *msgLocalID 消息的本地ID *uid 消息接受者返回值:无返回值
Message recipient Ack
方法名:-(void)onPeerMessageRemoteACK:(int)msgLocalID uid:(int64_t) uid功能:消息已经被对端接收到。参数说明: *msgLocalID 消息的本地ID *uid 消息接受者返回值:无返回值
Message failed to send
方法名:-(void) onPeerMessageFailure:(int)msgLocalID uid:(int64_t)uid功能:消息发出后,未收到服务器的ack,在和服务器的连接断开后,会通知消息发送失败。参数说明: *msgLocalID 消息的本地ID *uid 消息接受者返回值:无返回值
Class IMAPI set device token for the current user
Method Name:-(BOOL  Binddevicetoken:(nsstring *) devicetoken success:(void (^) ()) success fail:(void  (^) ()) fail function: Set device token im server pushes offline messages to users  parameter description: *devicetoken apns devicetoken  return value: boolean  is set successfully.  
Clears the device token associated with the current user
Method Name:-(BOOL)Unbinddevicetoken:(nsstring*)devicetoken Success:(void (^) ())success fail:(void  (^)()) fail function:im server no longer pushes offline message parameter description for this device : *devicetoken APNS  Devicetoken *accesstoken User's current accesstoken return value:boolean is cleared successfully.  
Imkit
    • In addition to imsdk necessary initialization actions, using Imkit requires the initialization of the storage class
    // Setdbpath must be called    before referencing Peermessagehandler,groupmessagehandler // The UID of the current login can be added to the path so that when different users log in, they can keep the previous user's chat history     [Messagedb Setdbpath:path];     = [Peermessagehandler instance];     = [Groupmessagehandler instance];
Open Chat Interface
messageviewcontroller* Msgcontroller == = = currentuid;[ Self.navigationcontroller Pushviewcontroller:msgcontroller Animated:yes];

Gobelieve IOS SDK Access Memo

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.