Why is my Parse Sign Up Code Not Getting Ran? - ios

In my main view controller, when a button is pressed I run the following code:
if (![PFUser currentUser]) { // No user logged in
// Create the log in view controller
CustomSignUp *logInViewController = [[CustomSignUp alloc] init];
[logInViewController setDelegate:self]; // Set ourselves as the delegate
// Create the sign up view controller
self.signUpViewController = [[TheActualSignUp alloc] init];
[self.signUpViewController setDelegate:self]; // Set ourselves as the delegate
self.signUpViewController.fields = (PFSignUpFieldsUsernameAndPassword
| PFSignUpFieldsSignUpButton
| PFSignUpFieldsEmail
| PFSignUpFieldsAdditional
| PFSignUpFieldsDismissButton);
[self.signUpViewController.signUpView.additionalField setPlaceholder:#"First & Last Name"];
[logInViewController setSignUpController:self.signUpViewController];
logInViewController.facebookPermissions = #[ #"email", #"public_profile", #"user_friends" ];
logInViewController.fields = (PFLogInFieldsUsernameAndPassword
| PFLogInFieldsFacebook
| PFLogInFieldsTwitter
| PFLogInFieldsLogInButton
| PFLogInFieldsSignUpButton
| PFLogInFieldsPasswordForgotten);
// Present the log in view controller
[self.navigationController pushViewController:logInViewController animated:YES];
}
The view controller for a login screen shows up, and I can successfully log in an already created user. However, when I try to sign up someone, I run into issues. The sign up window appears fine, and I type in all the codes, but when I click the button to send the info in to sign it up, nothing happens. Here is the code (in the same view controller). Would greatly appreciate any help on this. Am using Parse on Buddy.com. None of the NSLogs are getting called when signing up.
- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password {
// Check if both fields are completed
if (username && password && username.length != 0 && password.length != 0) {
return YES; // Begin login process
}
[[[UIAlertView alloc] initWithTitle:#"Missing Information"
message:#"Make sure you fill out all of the information!"
delegate:nil
cancelButtonTitle:#"ok"
otherButtonTitles:nil] show];
return NO; // Interrupt login process
}
// Sent to the delegate when a PFUser is logged in.
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
PFUser *me = [PFUser currentUser];
NSLog(#"Regular Login");
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error {
NSLog(#"Failed to log in...%#", error);
}
// Sent to the delegate when the log in screen is dismissed.
- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController {
[self.navigationController popViewControllerAnimated:YES];
}
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info {
NSLog(#"Signup");
BOOL informationComplete = YES;
// loop through all of the submitted data
for (id key in info) {
NSString *field = [info objectForKey:key];
if (!field || field.length == 0 || ![signUpController.signUpView.additionalField.text containsString:#" "] ) { // check completion
informationComplete = NO;
break;
}
}
// Display an alert if a field wasn't completed
if (!informationComplete) {
[[[UIAlertView alloc] initWithTitle:#"Missing Information"
message:#"Make sure you fill out all of the information, including first & last name!"
delegate:nil
cancelButtonTitle:#"ok"
otherButtonTitles:nil] show];
}
return informationComplete;
}
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
NSLog(#"Signed them up");
[user saveEventually];
[self dismissViewControllerAnimated:YES completion:nil]; // Dismiss the PFSignUpViewController
}
// Sent to the delegate when the sign up attempt fails.
- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error {
NSLog(#"Failed to sign up...");
}
// Sent to the delegate when the sign up screen is dismissed.
- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController {
NSLog(#"User dismissed the signUpViewController");
}

Looking through your code, it's not immediately obvious as to what the problem is. If you ping Parse on Buddy's customer support at support#buddy.com, we can help.

Related

Ios FBSDKGameRequestDialog send cancel method event

FBSDKGameRequestContent *content = [[FBSDKGameRequestContent alloc]init];
content.message = #"Great FB";
content.title = #"Invite Friends";
FBSDKGameRequestDialog *gameDialog = [[FBSDKGameRequestDialog alloc]init];
gameDialog.content = content;
gameDialog.frictionlessRequestsEnabled = YES;
gameDialog.delegate = self;
if ([gameDialog canShow]) {
[gameDialog show];
}
I am using the above code for showing FBFriends. The dialog is opened, but I want to perform some of my custom functionality after user hits send/cancel.
How should I do it?
You're doing:
gameDialog.delegate = self;
So, why don't you use the delegate methods (FBSDKGameRequestDialogDelegate): gameRequestDialogDidCancel: and
gameRequestDialog:didCompleteWithResults: to know if user has cancelled of sent its invitation?
Source
In your YourCurrentClass.h:
#interface YourCurrentClass : NSObject < FBSDKGameRequestDialogDelegate >
In your YourCurrentClass.m:
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didCompleteWithResults:(NSDictionary *)results
{
//User has done something.
//Check "results" and do something.
}
- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
{
//User has cancelled
//Do somathing
}
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didFailWithError:(NSError *)error
{
//An error happened
NSLog(#"Error: %#", error);
//Do something
}

App runs on iPhone 5s but not on iPhone 4s

I am using Xcode 6 beta with iOS 8 on the iPhone 5s the iphone 4s is standard ios 7.1 phone.
The app runs great on the iPhone 5s but as soon as a try a iphone 4s or the iPhone 4s simulator.
the app breaks out and throws the following error
dyld: Symbol not found: _NSURLAuthenticationMethodClientCertificate
Referenced from: /Users/MIkeAspinall 1/Library/Developer/CoreSimulator/Devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/data/Applications/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/WeddingsAndMore.app/WeddingsAndMore
Expected in: /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/CFNetwork.framework/CFNetwork
in /Users/MIkeAspinall 1/Library/Developer/CoreSimulator/Devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/data/Applications/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/WeddingsAndMore.app/WeddingsAndMore
(lldb)
I'm not sure why this is happening. But the iPhone 5s simulator throws the same error. It just seems to run on the iOS 8.
the settings are set for an ios 7.1 phone
im also using parse.com for my data access
My Phone is Iphone 5s Running ios 8 beta
iphone 4s is running ios 7.1
simulators are running in xcode 6beta
app is set to run on ios 7.1 or above.
i'm using xcode 6beta
hope that clears up what i have
opening code on first view controler
#interface DMKHomeViewController (UIViewcontroller )
#end
#implementation DMKHomeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(BOOL) hasInternet{
Reachability *reach = [Reachability reachabilityWithHostName:#"www.bbc.co.uk"];
NetworkStatus internetStats = [reach currentReachabilityStatus];
if (internetStats == NotReachable) {
UIAlertView *alertOne = [[UIAlertView alloc] initWithTitle:#"No Internet Connection" message:#" A connection To The Internet IS Required While Running This App. Please Reconnect To Continue" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:#"Cancel", nil];
[alertOne show];
}
else {
UIAlertView *alerttwo = [[UIAlertView alloc] initWithTitle:#"Internet Connection Active" message:#"A connection To The Internet IS Required While Running This App. Your Connection Is Live... Thankyou." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:#"Cancel", nil];
[alerttwo show];
}
return YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self hasInternet];
if (![PFUser currentUser]) { // No user logged in
// Create the log in view controller
PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init];
[logInViewController setDelegate:self]; // Set ourselves as the delegate
// Create the sign up view controller
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate
// Assign our sign up controller to be displayed from the login controller
[logInViewController setSignUpController:signUpViewController];
// Present the log in view controller
[self presentViewController:logInViewController animated:YES completion:NULL];
}
}
// Sent to the delegate to determine whether the log in request should be submitted to the server.
- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername: (NSString *)username password:(NSString *)password {
// Check if both fields are completed
if (username && password && username.length != 0 && password.length != 0) {
return YES; // Begin login process
}
[[[UIAlertView alloc] initWithTitle:#"Missing Information"
message:#"Make sure you fill out all of the information!"
delegate:nil
cancelButtonTitle:#"ok"
otherButtonTitles:nil] show];
return NO; // Interrupt login process
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
self.canDisplayBannerAds = YES;
}
// Sent to the delegate to determine whether the sign up request should be submitted to the server.
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info {
BOOL informationComplete = YES;
// loop through all of the submitted data
for (id key in info) {
NSString *field = [info objectForKey:key];
if (!field || field.length == 0) { // check completion
informationComplete = NO;
break;
}
}
// Display an alert if a field wasn't completed
if (!informationComplete) {
[[[UIAlertView alloc] initWithTitle:#"Missing Information"
message:#"Make sure you fill out all of the information!"
delegate:nil
cancelButtonTitle:#"ok"
otherButtonTitles:nil] show];
}
return informationComplete;
}
// Sent to the delegate when a PFUser is signed up.
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
[self dismissViewControllerAnimated:YES completion:NULL]; // Dismiss the PFSignUpViewController
}
// Sent to the delegate when the sign up attempt fails.
- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError: (NSError *)error {
NSLog(#"Failed to sign up...");
}
// Sent to the delegate when the sign up screen is dismissed.
- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController {
NSLog(#"User dismissed the signUpViewController");
}
// Sent to the delegate when a PFUser is logged in.
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
[self dismissViewControllerAnimated:YES completion:NULL];
}
// Sent to the delegate when the log in attempt fails.
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError: (NSError *)error {
NSLog(#"Failed to log in...");
}
// Sent to the delegate when the log in screen is dismissed.
- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
DMKHomeViewController *destination = [segue destinationViewController];
destination.interstitialPresentationPolicy = ADInterstitialPresentationPolicyAutomatic;
}
- (IBAction)Logout:(id)sender {
[PFUser logOut];
// Present the log in view controller
if (![PFUser currentUser]) { // No user logged in
// Create the log in view controller
PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init];
[logInViewController setDelegate:self]; // Set ourselves as the delegate
// Create the sign up view controller
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate
// Assign our sign up controller to be displayed from the login controller
[logInViewController setSignUpController:signUpViewController];
// Present the log in view controller
[self presentViewController:logInViewController animated:YES completion:NULL];
}
}

Error presentViewController - view controllers adding - objective c

I have a problem and can't know the reason or solution
I have AddDelegate and another ViewController, in this ViewController I add FBFriendPickerViewController, and ViewController will be added to AppDelegate ..
I add ViewController to AppDelegate like this: ( this ViewController is SocialSharing class )
if( socialSharing == nil )
socialSharing = [[SocialSharing alloc] init];
[_window.rootViewController.view addSubview:socialSharing.view];
And add FBFriendPickerViewController in ViewController(SocialSharing) like this:
-(void)shareOnFaceBook:(NSNotification *) notification
{
if( shareOnUserOrFriendWallBtnIndex == 0 )
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSURL *candidateURL = [NSURL URLWithString:contentDataToShare];
if (candidateURL && candidateURL.scheme && candidateURL.host) {
[facebookSheet setInitialText:#"See this link .."];
[facebookSheet addURL:candidateURL];
}
else // Event ***
{
[facebookSheet setInitialText:[NSString stringWithFormat:#"%#%#%#",[[appDelegate.extrasOverlayView.markerData.btnsArr objectAtIndex:0] objectForKey:#"markerName"],#" .. \n", contentDataToShare]];
[facebookSheet addURL:[NSURL URLWithString:lastVideoLink]];
}
//Brings up the little share card with the test we have pre defind.
[appDelegate.window.rootViewController presentViewController:facebookSheet animated:YES completion:nil];
} else {
//This alreat tells the user that they can't use built in socal interegration and why they can't.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"You can't send a tweet right now, make sure you have at least one Facebook account setup and your device is using iOS." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
}
else if( shareOnUserOrFriendWallBtnIndex == 1 )// post on friend's wall
{
if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fb://"]] )
{
NSLog(#"Facebook is inastalled on this device.");
if( friendPickerController == nil )
{
friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.delegate = self;
if( !( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) )
friendPickerController.title = #"Select Friends";
}
[friendPickerController loadData];
// Present view controller modally
[self presentViewController:friendPickerController animated:YES completion:nil];
}
else{
NSLog(#"This device has no Facebook app.");
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"You can't invite friends, Facebook app isn't installed, please install it and retry again." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
}
}
and dismiss friendPickerController from SocialSharing like:
- (void)facebookViewControllerCancelWasPressed:(id)sender
{
NSLog(#"Friend selection cancelled.");
[self dismissViewControllerAnimated:YES completion:nil];
}
I used:
[friendPickerController dismissModalViewControllerAnimated:YES];
OR //[self.view.window.rootViewController dismissViewControllerAnimated:YES completion:Nil];
OR //[self dismissModalViewControllerAnimated:YES];
It works good for only first time, once, friendPickerController appears and dismiss when close, BUT when call to open again, I have this error:
"Thread 1: signal SIGBRT"
FOR the line of :
[self presentViewController:friendPickerController animated:YES completion:nil];
Note: when I add friendPickerController on AppDelegate directly (in class of AppDelegate) without another class (here is SocialSharing ViewController), it works great ..
I'm working on IOS 7, and Facebook SDK 3.13..
So, What is the problem, How can I solve it ?
Thank you
What I did to solve my problem, I create friendPickerController in NORMAL CLASS , NOT ViewController, and add it on AppDelegate
[appDelegate.window.rootViewController presentViewController:friendPickerController animated:YES completion:nil];
and dismiss by:
[appDelegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
And call this Class like:
if( socialSharing == nil )
{
socialSharing = [[SocialSharingClass alloc] init];
[socialSharing initSocialSharing];
}
Still, I don't know the problem, but that solved it. May that help anyone.

how to Use Default LoginWithFacebook Button in my code

here is my code which is running properly but I want to use LoginWithFacebook default button which is provided by facebook.
Is there any image provided by facebook then please give me suggestion.
thankx in advance.....
#import "FacebbokViewController.h"
#import "UserAppAppDelegate.h"
#interface FacebbokViewController ()
#end
#implementation FacebbokViewController
- (id)init
{
self = [super init];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// button which I have used
UIButton *login=[[UIButton alloc]initWithFrame:CGRectMake(100,100, 200,80)];
[login setBackgroundColor:[UIColor blueColor]];
[login setTitle:#"login With facebook" forState:UIControlStateNormal];
[login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[login addTarget:self action:#selector(loginWithFacebook) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:login];
}
// method which excute on my button click
-(IBAction)loginWithFacebook{
UserAppAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"email", nil];
if(!appDelegate.session.isOpen)
{
// create a fresh session object
appDelegate.session = [[FBSession alloc] init];
[FBSession setActiveSession: appDelegate.session];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
else{
NSLog(#"hi");
}
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
// If the session was opened successfully
if (!error && state == FBSessionStateOpen){
NSLog(#"Session opened");
[self userData]; // method created to fetch user’s data.
// Show the user the logged-in UI
// do all the things as you have the info you requested from facebook
return;
}
if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){
// If the session is closed
NSLog(#"Session closed");
// Show the user the logged-out UI
[FBSession.activeSession closeAndClearTokenInformation];
}
// Handle errors
if (error){
NSLog(#"Error");
NSString *alertText;
NSString *alertTitle;
// If the error requires people using an app to make an action outside of the app in order to recover
if ([FBErrorUtility shouldNotifyUserForError:error] == YES){
alertTitle = #"Something went wrong";
alertText = [FBErrorUtility userMessageForError:error];
[self showMessage:alertText withTitle:alertTitle];
} else {
// If the user cancelled login, do nothing
if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) {
NSLog(#"User cancelled login");
// Handle session closures that happen outside of the app
} else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryAuthenticationReopenSession){
alertTitle = #"Session Error";
alertText = #"Your current session is no longer valid. Please log in again.";
[self showMessage:alertText withTitle:alertTitle];
// Here we will handle all other errors with a generic error message.
// We recommend you check our Handling Errors guide for more information
// https://developers.facebook.com/docs/ios/errors/
} else {
//Get more error information from the error
NSDictionary *errorInformation = [[[error.userInfo objectForKey:#"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:#"body"] objectForKey:#"error"];
// Show the user an error message
alertTitle = #"Something went wrong";
alertText = [NSString stringWithFormat:#"Please retry. \n\n If the problem persists contact us and mention this error code: %#", [errorInformation objectForKey:#"message"]];
[self showMessage:alertText withTitle:alertTitle];
}
}
// Clear this token
[FBSession.activeSession closeAndClearTokenInformation];
}
}
-(void)showMessage:(NSString*)alertMessage withTitle:(NSString*)alertTitle
{
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil] show];
}
-(void)userData
{
// Start the facebook request
[FBRequestConnection startWithGraphPath:#"me" parameters:[NSDictionary dictionaryWithObject:#"id,email" forKey:#"fields"] HTTPMethod:#"GET" completionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *result, NSError *error)
{
//if(!error){
// NSLog(#"result %#",result);
NSString *fbid =result[#"email"];
NSLog(#"result %#",fbid);
//}
}];
}
you can use FBLoginView to have the the functionality as your requirement , you can use like this
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.frame = YOURFRAME;
[self.view addSubview:loginView];
Take a look at FBLoginView in the Facebook SDK. Official link/tutorial. In the later part of the tutorial, implementing custom views and logging in with API calls is also covered. But note that you would have to design your button on your own in the latter case.

FBSession: should only be used from a single thread

I'm developing an app for FB wall posting in ios using facebook sdk 3.5. I'm using two views. Firts one is a splash screen and a second one is the facebook login view. When i'm activate both views I'm getting a thread and error displayed,
2013-05-17 17:07:59.115 [415:12503] * Assertion failure in -[FBSession checkThreadAffinity], /Users/chrisp/tmp/sdk/ios-sdk/src/FBSession.m:1571
2013-05-17 17:07:59.127 [415:12503] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FBSession: should only be used from a single thread'
* First throw call stack:
(0x2387052 0x1fa3d0a 0x232fa78 0x1a9c2db 0x21fa2 0x1e626 0x1ecd9 0x22b67 0x1eba3 0x3c265 0x2388ec9 0x11165c2 0x111655a 0x11bbb76 0x11bc03f 0x11bb2fe 0x113ba30 0x113bc56 0x1122384 0x1115aa9 0x293ffa9 0x235b1c5 0x22c0022 0x22be90a 0x22bddb4 0x22bdccb 0x293e879 0x293e93e 0x1113a9b 0x2be2 0x2b15)
terminate called throwing an exception(lldb)
Here is my Appdelegate.m code,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];
// Override point for customization after application launch.
self.viewController = [[[SplashViewController alloc] initWithNibName:#"SplashViewController" bundle:nil]autorelease] ;
// self.loginViewController = [[secondview alloc] initWithNibName:#"secondview"
// bundle:nil];
// self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.loginViewController];
// self.navigationController.delegate = self;
// self.window.rootViewController = self.navigationController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
//
//
UIBackgroundTaskIdentifier backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{NSLog(#"BackgroundTask Expiration Handler is called");
[application endBackgroundTask:backgroundTask];
}];
And this is the facebook_view.m code
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidUnload {
[self setFBLoginView:nil];
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - FBLoginView delegate
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
// Upon login, transition to the main UI by pushing it onto the navigation stack.
TNLRadioAppDelegate *appDelegate = (TNLRadioAppDelegate *)[UIApplication sharedApplication].delegate;
[self.navigationController pushViewController:((UIViewController *)appDelegate.viewController) animated:YES];
}
- (void)loginView:(FBLoginView *)loginView
handleError:(NSError *)error{
NSString *alertMessage = nil, *alertTitle;
// Facebook SDK * error handling *
// Error handling is an important part of providing a good user experience.
// Since this sample uses the FBLoginView, this delegate will respond to
// login failures, or other failures that have closed the session (such
// as a token becoming invalid). Please see the [- postOpenGraphAction:]
// and [- requestPermissionAndPost] on `SCViewController` for further
// error handling on other operations.
if (error.fberrorShouldNotifyUser) {
// If the SDK has a message for the user, surface it. This conveniently
// handles cases like password change or iOS6 app slider state.
alertTitle = #"Something Went Wrong";
alertMessage = error.fberrorUserMessage;
} else if (error.fberrorCategory == FBErrorCategoryAuthenticationReopenSession) {
// It is important to handle session closures as mentioned. You can inspect
// the error for more context but this sample generically notifies the user.
alertTitle = #"Session Error";
alertMessage = #"Your current session is no longer valid. Please log in again.";
} else if (error.fberrorCategory ==
FBErrorCategoryUserCancelled) {
// The user has cancelled a login. You can inspect the error
// for more context. For this sample, we will simply ignore it.
NSLog(#"user cancelled login");
} else {
// For simplicity, this sample treats other errors blindly, but you should
// refer to https://developers.facebook.com/docs/technical-guides/iossdk/errors/ for more information.
alertTitle = #"Unknown Error";
alertMessage = #"Error. Please try again later.";
NSLog(#"Unexpected error:%#", error);
}
if (alertMessage) {
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil] show];
}
}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
// Facebook SDK * login flow *
// It is important to always handle session closure because it can happen
// externally; for example, if the current session's access token becomes
// invalid. For this sample, we simply pop back to the landing page.
TNLRadioAppDelegate *appDelegate = (TNLRadioAppDelegate *)[UIApplication sharedApplication].delegate;
if (appDelegate.isNavigating) {
// The delay is for the edge case where a session is immediately closed after
// logging in and our navigation controller is still animating a push.
[self performSelector:#selector(logOut) withObject:nil afterDelay:.5];
} else {
[self logOut];
}
}
- (void)logOut {
[self.navigationController popToRootViewControllerAnimated:YES];
}
Cqan any one help???
It sounds like you're accessing your FBSession instance from more than one thread. Check that you're not calling [FBSession activeSession] or anything similar from a background thread (or that you're always calling it from the same background thread).

Resources