简体   繁体   中英

How can I know if the user is logged in some other device on same ID ,i used XMPP in my apps

I have implemented a chat application in iphone I want to know that whenever a user is already logged in and if he/she wants to login again in some other device using the same username & password, it should show pop up the user is logged in some other device .

I don't know which method to check the logged in status.

you have one method in appdelegate use that to solve it

- (void)xmppStream:(XMPPStream *)sender didNotAuthenticate:(NSXMLElement *)error
{
    // show the popup if user  didNotAuthenticate
}

this method may be help you

You can maintain a flag for Users in database at server side. When user logged in very first time, update database field value. Now next time when user tries to logged in from any other device, check value of database field wether, user is already logged in or not. If yes then display the message.

When the same JID logged in a new one,the old one will call this delegate: -(void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error , and Xcode will log like this: "Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}"

The above situation is established in the APP is activated in the state, if not, such as old one through the automatic login in, or access to the new equipment has been landing. @spaleja,his solution may a solution.

discuss

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM