function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
victor92victor92 

Log off

Hi, i really don`t know how to log out of my account in a native app with xcode, i expect someone could help me

cloudcodercloudcoder

 

 

try this for iOS:  (from http://wiki.developerforce.com/page/Getting_Started_with_the_Mobile_SDK_for_iOS)

 

- (void)logout {
   [self.coordinator revokeAuthentication];
    [self.coordinator authenticate];
}

 

or for Android: (from http://wiki.developerforce.com/page/Getting_Started_with_the_Mobile_SDK_for_Android)

 

ForceApp.APP.logout(MainActivity.this);

 

 

 

victor92victor92

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil aspirante:(NSDictionary *)_aspirante estatus:(NSArray *)_estatus
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        aspirante=_aspirante;
        self.title=[aspirante objectForKey:@"Apellido"];
        self.estatus=_estatus;
    }
    return self;
}
-(IBAction)update:(id)sender{
    
    NSArray *keys=[[NSArray alloc]initWithObjects:@"txmrecruitment__Apellido__c",@"txmrecruitment__Direccion__c", nil];
    NSArray *objs=[[NSArray alloc]initWithObjects:vistatexto.text,vistadireccion.text, nil];
    NSDictionary *fields=[[NSDictionary alloc] initWithObjects:objs forKeys:keys];
    SFRestRequest *request=[[SFRestAPI sharedInstance] requestForUpdateWithObjectType:@"txmrecruitment__Aspirante__c" objectId:[aspirante objectForKey:@"Id"] fields:fields];
    [[SFRestAPI sharedInstance] send:request delegate:self];
    /*NSArray *keys1=[[NSArray alloc]initWithObjects:@"txmrecruitment__Direccion__c", @"txmrecruitment__Estatus__c",nil];
    NSArray *objs1=[[NSArray alloc]initWithObjects:vistadireccion.text,selectedEstatus, nil];
    NSDictionary *fields1=[[NSDictionary alloc] initWithObjects:objs1 forKeys:keys1];
    SFRestRequest *request1=[[SFRestAPI sharedInstance] requestForUpdateWithObjectType:@"txmrecruitment__Aspirante__c" objectId:[aspirante objectForKey:@"Id"] fields:fields1];
    [[SFRestAPI sharedInstance] send:request1 delegate:self];*/
    
                            
}
-(IBAction)logout:(id)sender{
    [self._coordinator revokeAuthentication];
    [self._coordinator authenticate];
    
}

This is my code, the button logout doesn´t work, actually it doesnt do anything.

cloudcodercloudcoder

Have you set a breakpoint and can confirm that the logout action is actually getting called? If not, I would double-check your Nib is 'wired' up correctly.

mobillemobille

simply

 

in logout button action

write

 

- (void)LogOut

{

    SFNativeRestAppDelegate *nativeDelegate = (SFNativeRestAppDelegate *)[[UIApplicationsharedApplication]delegate];

    

    [nativeDelegate logout];

}

 

in SFNativeRestAppDelegate implement

 

 

- (void)logout {

[selfsetupAuthorizingViewController];

    [self.coordinatorrevokeAuthentication];

    [self.coordinatorauthenticate];

}