Open bintu1234 opened 8 years ago
Can you show the code how did you sign up?
On submit Method i did like this
[[self appDelegate] createNewAccountForXmppWithUserName:[[self phoneNumberTextField] text] withName:[[self nameTextField] text] andPassword:@"123456"]; [[self appDelegate] connect];
after this it calling connect then goOnline But not calling xmppStreamDidAuthenticate.
even it is not showing as online
in appdelegate create user like below `-(BOOL)createNewAccountForXmppWithUserName:(NSString)userNameJID withName:(NSString *)name andPassword:(NSString)userPassword{
if (userNameJID == nil || userPassword == nil || name==nil) {
return NO;
}
NSString *domain=@"mac-mini-2.local";
self.xmppStream.hostName = domain;
int port = 5222;
self.xmppStream.hostPort = port;
useSSL = NO;
customCertEvaluation = NO;
userName = [NSString stringWithFormat:@"%@@mac-mini-2.local",userNameJID]; XMPPJID jid = [XMPPJID jidWithString:userName resource:nil]; self.xmppStream.myJID = jid; NSError error = nil; BOOL success; // success = [[self xmppStream] registerWithPassword:password withName:name error:&error]; password = userPassword; currentUserName=name; if(![[self xmppStream] isConnected]) { if (useSSL) success = [[self xmppStream] oldSchoolSecureConnectWithTimeout:XMPPStreamTimeoutNone error:&error]; else success = [[self xmppStream] connectWithTimeout:XMPPStreamTimeoutNone error:&error];
// success = [[self xmppStream] registerWithPassword:password withName:name error:&error];
}
else
{
success = [[self xmppStream] registerWithPassword:password withName:name error:&error];
}
if (success)
{
isRegistering = YES;
// NSLog(@"Successfully Register on XMPP Server");
}
return YES;
} `
but if i close app and reopen then it's working fine
What do you mean close app? Do you mean actually kill it or just send it to background?
Anyway, this code looks fine. I wonder problem could be in the way that you create xmppStream
. Can you post that code?
my connect Method like
`if ([xmppStream isDisconnected]) { NSLog(@"===================%d", [self.xmppStream isConnected]);
return YES;
}
NSString *myJID=[NSString stringWithFormat:@"%@@-mac-mini-2.local",[[NSUserDefaults standardUserDefaults] stringForKey:@"userNameJID"]];
NSString *myPassword =@"123456";
if (myJID == nil || myPassword == nil) {
return NO;
}
[xmppStream setMyJID:[XMPPJID jidWithString:myJID]];
password = myPassword;
NSError *error = nil;
if (![xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting"
message:@"See console for error details."
delegate:nil
cancelButtonTitle:NSLocalizedString( @"O_K", @"OK")
otherButtonTitles:nil];
[alertView show];
DDLogError(@"Error connecting: %@", error);
NSLog(@"===================%@",error);
return NO;
}
NSLog(@"===================inside connect");
return YES;
`
and my xmppstream method is like `xmppStream = [[XMPPStream alloc] init]; xmppStream.hostName =@"mac-mini-2.local"; xmppStream.hostPort = 5222;
{
xmppStream.enableBackgroundingOnSocket = YES;
}
#endif
xmppReconnect = [[XMPPReconnect alloc] init]; xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init]; xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore]; xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage]; [[self xmppRoster] setAutoFetchRoster:YES]; xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance]; xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage]; xmppvCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:xmppvCardTempModule]; xmppCapabilitiesStorage = [XMPPCapabilitiesCoreDataStorage sharedInstance]; xmppCapabilities = [[XMPPCapabilities alloc] initWithCapabilitiesStorage:xmppCapabilitiesStorage]; xmppCapabilities.autoFetchHashedCapabilities = YES; xmppCapabilities.autoFetchNonHashedCapabilities = NO; xmppMessageArchivingStorage =[XMPPMessageArchivingCoreDataStorage sharedInstance]; xmppMessageArchivingModule = [[XMPPMessageArchiving alloc] initWithMessageArchivingStorage:xmppMessageArchivingStorage]; [xmppMessageArchivingModule setClientSideMessageArchivingOnly:YES]; [xmppReconnect activate:xmppStream]; [xmppRoster activate:xmppStream]; [xmppvCardTempModule activate:xmppStream]; [xmppvCardAvatarModule activate:xmppStream]; [xmppCapabilities activate:xmppStream]; [xmppMessageArchivingModule activate:xmppStream]; [xmppPing activate:xmppStream]; [xmppTime activate:xmppStream]; [xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppCapabilities addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppMessageArchivingModule addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppvCardAvatarModule addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppvCardTempModule addDelegate:self delegateQueue:dispatch_get_main_queue()]; customCertEvaluation = YES; // Initialize other stuff turnSockets = [[NSMutableArray alloc] init];` please help me
Where do you call this setUpStream
method? It is better if you can post the whole steps of what did you do.
First my signup Viewcontroller will show if user first time using app for that what i'm doing is : in didFinishLaunchingWithOptions i use below code
`NSString *savedValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"userNameJID"];
//savedValue=nil;
if (savedValue.length==0) {
//go to sign up
}
else{
//conect when their is user login
[self connect];
//navigation to home screen
self.window.rootViewController =[self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"loggedInViewController"];
}
`
in my signup page i'm saving my userId and i'm using here
after this im' calling [self setupStream]; in didFinishLaunchingWithOptions
Hmm, it doesn't help much. I can't tell much about this situation but it looks to me that your stream may be nil in the first time you launch the app. Try to check and make sure that you have correctly set it up before calling the connect method.
@sahara108 Thanks for the replay one more thing when i send presence to server i got this RECV Stanza like below
SEND: <presence><x xmlns="vcard-temp:x:update"><photo/></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/></presence> 2016-03-11 13:25:57:701 Zipgo[2582:760b] RECV: <presence xmlns="jabber:client" to="harjits-mac-mini-2.local/31yyhogz3q" type="error"><x xmlns="vcard-temp:x:update"><photo/></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></presence>
It is showing error as not-authorized can you please tell why it is showing like that. Please help me
It may be because you haven't authenticated with the server. In the - (void)xmppStreamDidConnect:(XMPPStream *)sender;
try to authenticate with provided password.
NSError *error; [_stream authenticateWithPassword:[_account getPassword] error:&error];
@sahara108 Thanks for the replay already i tried with that but at this moment only i'm getting below log when i send presence after Registering
<presence xmlns="jabber:client" to="mac-mini-2.local/31yyhogz3q" type="error"><x xmlns="vcard-temp:x:update">
in above TO is showing only server Name not user name when i'm close my app and reopen then it is showing
<presence xmlns="jabber:client" from="654@mac-mini-2.local/495xiebiy" to="654@mac-mini-2.local/495xiebiy"><x xmlns="vcard-temp:x:update"><photo/></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/></presence>
At this time it is showing TO with UserName . How i'm adding my userJID to Openfire srever is
userName = [NSString stringWithFormat:@"%@@mac-mini-2.local",userNameJID]; XMPPJID *jid = [XMPPJID jidWithString:userName resource:nil]; self.xmppStream.myJID = jid;
and my didconnect like below `- (void)xmppStreamDidConnect:(XMPPStream *)sender { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); isOpen=YES; isXmppConnected=YES;
NSError *error = nil;
BOOL operationInProgress;
if (isRegistering)
{
operationInProgress =[[self xmppStream] registerWithPassword:password error:&error];
}
else
{
operationInProgress =[[self xmppStream] authenticateWithPassword:password error:&error];
}`
where i'm missing can you please help me.
Hi i am working with the Xmpp Framework. I got a problem regarding the Delegate Method every thing is working fine but when i signup my xmppStreamDidAuthenticate not calling first time when i close my app and reopen then it is calling where i am missing?