You need to sign in to do that
Don't have an account?
How do I output username in iOS SDK using OAuth?
Hello,
I've followed a few pointers and tutorials around the web for the task I am trying to complete, but nothing has worked so far.
I've added what I believe to be the necessary SDK components to my XCode Project (still using 4.3, not 5.0 for iOS 7). I've setup a new view controller and included it in my navigation controller. This view is for a new 'Settings' page I am trying to create.
Currently user authentication works just fine with the authenticator view. However, this is the class I am using to try and output data to three labels after login and navigation to the Settings view:
#import "SQSettingsViewController.h" #import "SFAccountManager.h" #import "SFIdentityData.h" @interface SQSettingsViewController () @end @implementation SQSettingsViewController @synthesize salesforceFirstName, salesforceLastName, salesforceUsername, firstNameLabel, lastNameLabel, usernameLabel; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. salesforceUsername = [SFAccountManager sharedInstance].idData.username; salesforceFirstName = [SFAccountManager sharedInstance].idData.firstName; salesforceLastName = [SFAccountManager sharedInstance].idData.lastName; firstNameLabel.text = salesforceFirstName; lastNameLabel.text = salesforceLastName; usernameLabel.text = salesforceUsername; NSLog(@"Username: %@, first name: %@, Last Name: %@", salesforceUsername, salesforceFirstName, salesforceLastName); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
And the output I get in my console:
2013-07-29 08:44:28.099 Sequoia[26397:c07] SFOAuthCoordinator:authenticate: authenticating as REDACTED.REDACTED.REDACTED.REDACTED with refresh token on 'https://login.salesforce.com' ... 2013-07-29 08:44:28.342 Sequoia[26397:c07] oauthCoordinatorDidAuthenticate for userId: REDACTED 2013-07-29 08:44:32.738 Sequoia[26397:c07] Username: (null), first name: (null), Last Name: (null)
Any pointers here? I'm at a loss because the only thing I see for REST API usage is SFIdentityData... a little confused! Any help is appriciated!
Thank you!
I'm using a shared instance but the object is never instantiated. Values continue to be null, and I feel as though I really just don't have a handle on how Salesforce handles OAuth :-(
I have uploaded my xcode project here: https://www.dropbox.com/s/8pb8ra9nbl2q0tg/NativeSDKApp.zip
Again, I have tried this on XCode 5 with iOS 7. Hope this helps!