methods - ios xmpp call another viewcontroller from oneview controller through appdelegate -


i working on xmpp project. have created connection , able login successfully.but have setup methods , in appdelegate [connect] method. when login in app when have fetch friend list have again call appdelegate [connect] method want set condition , in viewcontroller loginbutton. when secondtime appdelegate [connect] method call not affect other view controller , result. have tried declaring bool method not successful. here try.

//appdelegate.m file//   -(bool) isauthenticate; // mthod declaration       - (bool)connect    {   //  hud = [mbprogresshud showhudaddedto:self.navigationcontroller.view animated:yes] ;    //hud.delegate = self;        hud = [[mbprogresshud alloc ] initwithwindow:[uiapplication sharedapplication ].keywindow];    [self.window.rootviewcontroller.view  addsubview:hud];     [hud setdetailslabeltext:@"please wait..."];     [hud setdimbackground:yes];     [hud setopacity:0.5f];     [hud show:yes];    // hud.color =[uicolor colorwithpatternimage:[uiimage imagenamed:@"logo"]];    // [hud hide:yes afterdelay:10.0];      if (![xmppstream isdisconnected]) {     return yes;     // isauthenticate=yes;    }     nsstring *myjid = [[nsuserdefaults standarduserdefaults] stringforkey:kxmppmyjid];    nsstring *mypassword = [[nsuserdefaults standarduserdefaults] stringforkey:kxmppmypassword];     //    // if don't want use settings view set jid,    // uncomment section below hard code jid , password.    //    // myjid = @"user@gmail.com/xmppframework";    // mypassword = @"";     if (myjid == nil || mypassword == nil) {      return no;    }     [xmppstream setmyjid:[xmppjid jidwithstring:myjid]];    password = mypassword;     nserror *error = nil;    if (![xmppstream connectwithtimeout:xmppstreamtimeoutnone error:&error])    {      hud.hidden=yes;      uialertview *alertview = [[uialertview alloc] initwithtitle:@"error connecting"                                                         message:@"see console error details."                                                        delegate:nil                                               cancelbuttontitle:@"ok"                                               otherbuttontitles:nil];      [alertview show];     //  ddlogerror(@"error connecting: %@", error);       // return no;     }  return yes;     } 

here viewcontroller.m file

             //viewcontroller.m file//          - (ibaction)checklogin:(id)sender {          [self dismisskeyboard];         // hud = [mbprogresshud showhudaddedto:self.navigationcontroller.view animated:yes] ;        // hud.delegate = self;         nslog(@"email: %@  password: %@",mviewemail.text,mviewpassword.text);        [self setfield:mviewemail forkey:kxmppmyjid];      [self setfield:mviewpassword forkey:kxmppmypassword];       if ([[self appdelegate ]connect])      {      if (appdelegate.isauthenticate==yes) {       //appdelegate.isauthenticate=yes;          [self showhome];        }        else         {               uialertview *alert = [[uialertview alloc] initwithtitle:@"sorry"                                                         message:@"please check username or password"                                                        delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil];             [alert show];            }          }             }                     - (void)showhome{       //[[self appdelegate]isauthenticate];      [self performseguewithidentifier:@"signin" sender:self];             } 

what solution ?

1) not terminate xmpp session.

2) if have active session of xmpp there no need call connect method of app delegate.

3) if session expire call connect methods.

4) retrieve friends list, have manage roster on xmpp server using ios xmpp client.

5) can roster list calling getallroster method of xmpproster class otherwise can implement xmpp roster protocol in class.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -