I having problem with the log out from facebook. It should log out the current user and back to the main page but now It back to the main page but it pop back to the current screen with the empty field that which I already clear using closeAndClearTokenInformation. Anyone please help.Thanks.
- (IBAction)LogOutAction {
[appDelegate readPersonsFromDatabase:kPERSON_TYPE_OWNER withPersonName:#"" withPersonBirthday:NO];
if ([appDelegate.myIPPersonArray count] > 0) {
self.myIPPerson = [[IP_PERSON alloc] initWithInternalNum:#"1" personType:kPERSON_TYPE_OWNER personID:#"" personName:#"" personCompany:#"" personAddress1:#"" personAddress2:#"" personCity:#"" personState:#"" personPostcode:#"" personCountry:#"" personEmail:#"" personPhoto:#"" personDOB:#"" userDef1:#"" userDef2:#"" userDef3:#"" userDef4:#"" userDef5:#"" userDef6:#"" userDef7:0 userDef8:0 status:#"0"];
[self.myIPPerson setPersonCredit:#"0"];
[appDelegate insertOrUpdatePersonToDatabase:self.myIPPerson];
}
[FBSession.activeSession closeAndClearTokenInformation];
[self.navigationController popToRootViewControllerAnimated:YES];
}
Related
I am trying to create a function with iOS facebook sdk where I will be able to login and if I am logged in I will be able to see the nslog string "logged in". However I am not seeing it the string at all. Also, the login seems to be working fine in terms of pushing button and seeing my Facebook app and pressing ok to continue. Can someone inform me on what I am doing wrong?
-(IBAction)popButton:(id)sender {
TUAppDelegate *appDelegate = (TUAppDelegate *)[[UIApplication sharedApplication] delegate];
// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {
// if a user logs out explicitly, we delete any cached token information, and next
// time they run the applicaiton they will be presented with log in UX again; most
// users will simply close the app or switch away, without logging out; this will
// cause the implicit cached-token login to occur on next launch of the application
[appDelegate.session closeAndClearTokenInformation];
} else {
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new session state
[self updateView];
}];
}
}
- (void)updateView{
// get the app delegate, so that we can reference the session property
TUAppDelegate *appDelegate = (TUAppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.session.isOpen) {
NSLog(#"Logged In");
} else {
NSLog(#"Not Logged In");
}
}
I suspect you've missed at least step 2d, wiring the openURL back to the Facebook SDK:
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/
... that said, you could easily have missed more. If you are seeing your app again after login then I suspect you've added the URL scheme to your Info.plist, otherwise check that also.
I have the next issue I'm creating one view when one button is touched. when the view is created and loaded I make 2 request with ASIFormDataRequest one request for download one Image and the other for get some text.
The headache become when the user in the view loaded select back because if button back is pressed the view is removed form superview, but crashh if one request callback is coming and the view dont exist how can I make this like cancel the request or how can I fix that.
The crash is in the next line of code
Class: ASIHTTPRequest.m
BOOL dataWillBeHandledExternally = NO;
**if ([[self delegate] respondsToSelector:[self didReceiveDataSelector]]) {**
dataWillBeHandledExternally = YES;
}
With: Thread 6: EXC_BAD_ACCES (code = 1, address = 0x30047dbc)
Please hellp that has haunted me.
You want to make sure that you cancel any pending ASIHTTPRequest when you pop your view:
From: http://allseeing-i.com/ASIHTTPRequest/How-to-use#cancelling_an_asychronous_request
// Cancels an asynchronous request, clearing all delegates and blocks first
[request clearDelegatesAndCancel];
You can use try catch for it. below is how u can do in ASIHTTPRequest.m
#try {
if ([[self delegate] respondsToSelector:[self didReceiveDataSelector]]) {
dataWillBeHandledExternally = YES;
}
}
#catch (NSException *exception) {
dataWillBeHandledExternally = NO;
}
I have an iPhone game in which players can tweet their score.
I use TWTweetComposeViewController for this.
Since the Twitter sheet can take some time to load, I would like a "loading..." layer to show up after the player has clicked the tweet button, while waiting for the Twitter sheet to show up.
My problem is that the layer (named "colcol" in the code below) only shows up once the tweet sheet is ready! It's as if the layer waited for the tweet sheet to be ready to show up. Which is definitely not what I expect.
Any idea why ?
Thank you!
Here is the tweetScore function, called when the user touches a CCMenuItemImage:
- (void) tweetScore: (CCMenuItem *) menuItem {
colcol=[CCLayerColor layerWithColor:ccc4(0,0, 0, 200) width:50 height:50];
colcol.position=ccp(winSize.width/2-25,winSize.height/2-25);
[self addChild:colcol z:15];
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:[NSString stringWithFormat:#"I scored %d!", playerScore]];
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result) {
[appDelegate.viewController dismissModalViewControllerAnimated:YES];
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
[self removeChild:colcol cleanup:YES];
break;
case TWTweetComposeViewControllerResultDone:
[[GCHelper sharedInstance] reportAchievementIdentifier:#"tweet_score" percentComplete:100.0];
[self removeChild:colcol cleanup:YES];
break;
default:
[self removeChild:colcol cleanup:YES];
break;
}
};
[appDelegate.viewController presentModalViewController:tweetSheet animated:YES];
}
else
{
// handle this case
}
}
In general, screen updates in CoreAnimation, UIKit, and OS X are deferred until the end of the current pass through the run loop. You are adding the CALayer, then doing some time-consuming work (setting up the TWTweetComposeViewController), then returning so the run loop can finish -- so there's no time for a screen update to happen in between.
Try setting up the TWTweetComposeViewController in a separate pass through the run loop, using dispatch_async(dispatch_get_main_queue(), ^{ /* your code here */ }).
i am using Twitter with IOS - 5 integration. i used tweeting app provide by apple for this.I am using TWTweetComposeViewController for this.
But if i have more than 2 twitter accounts. it is getting my first account every time. but i want that list of my different account shown to me and then when i select one of account and then i can use it with TWTweetComposeViewController. i like to show like bellow image From :"username"
i have used this code :
- (IBAction)sendEasyTweet:(id)sender {
// Set up the built-in twitter composition view controller.
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
// Set the initial tweet text. See the framework for additional properties that can be set.
[tweetViewController setInitialText:#"Hello. This is a tweet."];
[tweetViewController addImage:[UIImage imageNamed:#"Icon.png"]];
// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
NSString *output;
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
// The cancel button was tapped.
output = #"Tweet cancelled.";
break;
case TWTweetComposeViewControllerResultDone:
// The tweet was sent.
output = #"Tweet done.";
break;
default:
break;
}
[self performSelectorOnMainThread:#selector(displayText:) withObject:output waitUntilDone:NO];
// Dismiss the tweet composition view controller.
[self dismissModalViewControllerAnimated:YES];
}];
// Present the tweet composition view controller modally.
[self presentModalViewController:tweetViewController animated:YES];
}
Unfortunately, TWTweetComposeViewController doesn't give you much configuration flexibility. If you tap on the account name it will pop up your list of accounts. TWTweetCVC does seem to remember the last account you tweeted with though.
If you use ACAccountStore you can get the list of the users Twitter accounts and you could provide your own UI to choose one but you cannot configure TWTweetComposeViewController to use it. If you couple that with TWRequest you can roll your own tweet sheet class and do this yourself.
DETweetComposeViewController is a drop-in replacement for TWTweetComposeViewController. It's open source, so you can modify it to meet your needs. It's also compatible with iOS 4.
Now , i am getting my it , and picker is showing for it as shown in image
so from this picker , i can select one of my account for tweet.
I am using FBConnect API...And I am using this code while pressing button..
- (IBAction)postGradesTapped:(id)sender {
_posting = YES;
// If we're not logged in, log in first...
if (![_session isConnected]) {
self.loginDialog = nil;
_loginDialog = [[FBLoginDialog alloc] init];
[_loginDialog show];
}
// If we have a session and a name, post to the wall!
else if (_facebookName != nil) {
[self postToWall];
}
// Otherwise, we don't have a name yet, just wait for that to come through.
}
Now when I press the button...
White blank screen Comes up...:(
What can be the problem??
As per your code, on login success you are posting on your wall. So it may be getting blank screen. Try print something on console on login success.