xmppframework - iOS XMPP Framework, how to handle wrong credential? -
all codes use https://github.com/robbiehanson/xmppframework. inside sample code.
in ios7 messaging app, invoke "connect" function inside xmpp framework after user has entered login credential , clicked "login" button. connect function works fine if entered correct credentials first time, not work if user entered wrong credential. because first line inside connect return true:
if (![_xmppstream isdisconnected]) { return yes; }
which means further presses on login button nothing.
should manually invoke authenticatewithpassword? right practice assuming connection between client , server has been setup?
thank you.
you need use methods in delegate handle authentication. first need connect server if it's not connected:
[_xmppstream connectwithtimeout:10 error:&error];
once stream connected server delegate method invoked:
- (void)xmppstreamdidconnect:(xmppstream *)sender;
inside method, can call authenticatewithpassword
. if stream connected (would else part of if posted) can call authenticatewithpassword
.
if authentication fails, following delegate method called:
- (void)xmppstream:(xmppstream *)sender didnotauthenticate:(nsxmlelement *)error;
there can decide show message user , start over. if authentication succeeds, following method called:
- (void)xmppstreamdidauthenticate:(xmppstream *)sender;
Comments
Post a Comment