When linking my iOS with Facebook through Parse with the following code I get the following error:
+[PFDateFormatter sharedFormatter]: unrecognized selector sent to class 0x1001f31d0
Unsure of how to handle this, and this error executes when the following block is called:
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
[_activityIndicator stopAnimating]; // Hide loading indicator
if (!user) {
NSString *errorMessage = nil;
if (!error) {
NSLog(#"Uh oh. The user cancelled the Facebook login.");
errorMessage = #"Uh oh. The user cancelled the Facebook login.";
} else {
NSLog(#"Uh oh. An error occurred: %#", error);
errorMessage = [error localizedDescription];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Log In Error"
message:errorMessage
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:#"Dismiss", nil];
[alert show];
} else {
if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
} else {
NSLog(#"User with facebook logged in!");
}
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
I fixed this by removing all the Parse and Facebook frameworks from my project, and then adding this to my podfile:
pod 'Facebook-iOS-SDK'
pod 'Parse'
pod 'ParseFacebookUtils'
and reinstalling my podfile. For whatever reason, something is missing from the Parse or Facebook frameworks downloaded from the website. The podfiles fixed the issue for me.
Related
I have downloaded Parse's app, Anypic, but cannot get it to run properly on my phone. I have completed all of the required steps and it says "build succeeded" when I run it.
However, all that shows up is a black screen and a Facebook "login" button. When the button is clicked, you can login to Facebook but then it just changes the button to say "log out" which is not exactly wha
I have attached a picture with all my warnings I get. Are the warnings the issue or is there something else I need to change in the code? Thanks!
You should change handleFacebookSession part to look like this:
- (void)handleFacebookSession {
if ([PFUser currentUser]) {
if (self.delegate && [self.delegate respondsToSelector:#selector(logInViewControllerDidLogUserIn:)]) {
[self.delegate performSelector:#selector(logInViewControllerDidLogUserIn:) withObject:[PFUser currentUser]];
}
return;
}
NSArray *permissionsArray = #[ #"public_profile",
#"user_friends",
#"email"];
self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
if (!user) {
NSString *errorMessage = nil;
if (!error) {
NSLog(#"Uh oh. The user cancelled the Facebook login.");
errorMessage = #"Uh oh. The user cancelled the Facebook login.";
} else {
NSLog(#"Uh oh. An error occurred: %#", error);
errorMessage = [error localizedDescription];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Log In Error"
message:errorMessage
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:#"Dismiss", nil];
[alert show];
} else {
if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
} else {
NSLog(#"User with facebook logged in!");
}
if (!error) {
[self.hud removeFromSuperview];
if (self.delegate) {
if ([self.delegate respondsToSelector:#selector(logInViewControllerDidLogUserIn:)]) {
[self.delegate performSelector:#selector(logInViewControllerDidLogUserIn:) withObject:user];
}
}
} else {
[self cancelLogIn:error];
}
}
}];}
Found here.
I'm using Twitter SDK to loggin and tweet. Authenticate it's ok, but when use TWTRComposer with a simple text, the SDK callback return 'TWTRComposerResultDone', but the Simulator/Device show 'The tweet "text" cannot be sent because the connection to Twitter failed.
The debugger show 'plugin com.apple.share.Twitter.post invalidated' but everything aparently is correct.
Is there a bug or I forgot some thing.
My code:
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:#"some text"];
[composer showWithCompletion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(#"Tweet composition cancelled");
}
else {
NSLog(#"Sending Tweet!");
}
}];
Tweet Using SDK
1. Crearte App on twitter.developer
2. add twitter frameworks like TwitterCore.framework, TwitterKit.framework, Fabric.framework, TwitterKitResources.bundle
3. write below code in tweet button
[[Twitter sharedInstance] startWithConsumerKey:#"YourConsumerKey" consumerSecret:#"YourConsumerSecret"];
[Fabric with:#[[Twitter sharedInstance]]];
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)
{
if (session)
{
NSLog(#"logged in user with id %#", session.userID);
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:#"Enter Your Tweet Message"];
//[composer setImage:[UIImage imageNamed:#"fabric"]];
[composer showFromViewController:self completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled)
{
NSLog(#"Tweet composition cancelled");
}
else
{
NSLog(#"Sending Tweet!");
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"" message:#"Sent Tweet!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
}
}];
}
else
{
// log error
}
}];
When I submit with empty textbox page is change and UIAlertView show after that, but I want to UIAlertView show in current page and page can not change (Stay on Signin Viewcontroller).
Thanks
- (IBAction)btnSignin:(id)sender {
[PFUser logInWithUsernameInBackground:_txtSigninUsername.text password:_txtSigninPassword.text block:^(PFUser *user, NSError *error) {
if (!error) {
NSLog(#"Login user!");
_txtSigninUsername.text = nil;
_txtSigninPassword.text = nil;
[self performSegueWithIdentifier:#"Signin" sender:self];
}
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"ooops!" message:#"Sorry we had a problem logging you in" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}];
}
My Storyboard :
You're performing the Segue with "Signin" identifier with the condition "error".
So when there's an error first your code performs the segue and then performs the error message.
Change "!error" with "user" and it should hopefully work. Let me know.
My Project is to get Facebook Insights data of my Fanpage on my iPhone App.
I started by installing Facebook SDK for iOS to get Access Code & than using SampleLoginSample Sample Program provided with Facebook iOS SDK.
Its working Perfect & giving same response as in Facebook API Explporer for Query
[self.textNoteOrLink setText:
[NSString stringWithFormat:#"https://graph.facebook.com/[PAGEID]?fields=likes&access_token=%#",appDelegate.session.accessTokenData.accessToken]];
but if i am writing below Query its not giving me response as in Facebook Explorer API
QUERY:
[self.textNoteOrLink setText:
[NSString stringWithFormat:#"https://graph.facebook.com/PAGEID/insights/page_fans?access_token=%#",appDelegate.session.accessTokenData.accessToken]];
RESPONSE:
{"data":[
],"paging":{
"previous":"https:\/\/graph.facebook.com\/PAGEID\/insights\/page_fans?access_token=CAA...snip...h2l&since=1378984583&until=1379243783","next":"https:\/\/graph.facebook.com\/PAGEID\/insights\/page_fans?access_token=CAA...snip...h2l&since=1379502983&until=1379762183"}}
Can anyone help me to get access code with get_insights permission in Facebook iOS SDK?
In SLAppDelegate.h
Under the list of #property, add:
-(BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI;
In SLAppDelegate.m
Under applicationDidBecomeActive, add:
/*
* Opens a Facebook session and optionally shows the login UX.
*/
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"read_insights",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
And:
/*
* Callback for session changes.
*/
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
if (!error) {
// We have a valid session
NSLog(#"User session found");
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
[FBSession.activeSession closeAndClearTokenInformation];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
}
In SLViewController.h
At the end of viewDidLoad , add:
[appDelegate openSessionWithAllowLoginUI:NO];
I updated both Parse and Facebook iOS SDKs to the latest versions, and when I try to login using Facebook my app crashes, and from the debugger I can see that it is calling 3-4 methods in an endless loop.
My login code looks like this:
- (void)openSession
{
UIViewController *topViewController = self.window.rootViewController;
NSArray *permissions = [NSArray arrayWithObjects:#"user_likes", #"friends_likes", nil];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
if (!error) {
NSLog(#"Uh oh. The user cancelled the Facebook login.");
} else {
NSLog(#"Uh oh. An error occurred: %#", error);
}
} else if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
if ([[topViewController presentedViewController] isKindOfClass:[PALoginViewController class]]) {
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
} else {
NSLog(#"User with facebook logged in!");
if ([[topViewController presentedViewController] isKindOfClass:[PALoginViewController class]]) {
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
}
}];
}
The error occurs when logInWithPermissions is called. It crashes into Xcode and Debugger is showing an awful lot of calls to FB login methods - thousands actually:
What could be wrong?
This issue was reported as a bug on Facebook: https://developers.facebook.com/bugs/188127071335876?browse=search_5176d24c698df3761093726
It has now been fixed, and I can confirm that logging in now works - even with Sandbox enabled.
Sandbox off, then it should works.