Sport
Sport

Reputation: 8945

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.

Upvotes: 0

Views: 605

Answers (3)

Ferry
Ferry

Reputation: 3

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

Upvotes: 0

user2913709
user2913709

Reputation:

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

Upvotes: 3

spaleja
spaleja

Reputation: 1435

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.

Upvotes: 0

Related Questions