FBFriendPickerViewController Crashing - iphone

a few days ago I had this working where after you login to facebook you can click a button and an FBFriendPickerViewController would appear with a list of all facebook friends. However, suddenly it has started to crash with some weird errors. Here is my code:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [FBSession.activeSession handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [FBSession.activeSession handleOpenURL:url];
}
In my home viewcontroller.m
// Pick Friends button handler
- (IBAction)pickFriendsClick:(UIButton *)sender {
// Create friend picker, and get data loaded into it.
FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
self.friendPickerController = friendPicker;
[friendPicker loadData];
// Create navigation controller related UI for the friend picker.
friendPicker.navigationItem.title = #"Pick Friends";
friendPicker.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:#"Done"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(friendPickerDoneButtonWasPressed:)];
friendPicker.navigationItem.hidesBackButton = YES;
// Make current.
[self.navigationController pushViewController:friendPicker animated:YES];
}
// Handler for when friend picker is dismissed
- (void)friendPickerDoneButtonWasPressed:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
NSString *message;
if (self.friendPickerController.selection.count == 0) {
message = #"<No Friends Selected>";
} else {
NSMutableString *text = [[NSMutableString alloc] init];
// we pick up the users from the selection, and create a string that we use to update the text view
// at the bottom of the display; note that self.selection is a property inherited from our base class
for (id<FBGraphUser> user in self.friendPickerController.selection) {
if ([text length]) {
[text appendString:#", "];
}
[text appendString:user.name];
}
message = text;
}
[[[UIAlertView alloc] initWithTitle:#"You Picked:"
message:message
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil]
show];
}
And finally here is the error message I am getting when the button set up to the pickFriendsClick method is hit:
2012-07-18 19:22:14.978 MeetUp[7213:1dc03] -[__NSDictionaryI length]: unrecognized selector sent to instance 0xa9b7c70
2012-07-18 19:22:14.980 MeetUp[7213:1dc03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0xa9b7c70'
* First throw call stack:
(0x1f626a2 0x13ede7e 0x1feda3d 0x1f522bc 0x1f5204e 0x1edd7d0 0x1ef5c98 0x1fcff7b 0x1ef5b42 0xde4d5a 0xe3ace8 0xe3ac93 0x20138 0x20718 0x410ffb 0x4110cf 0x3f9e1d 0x40a4db 0x3a79ba 0x14016be 0x25a53a6 0x259973c 0x2599550 0x2517690 0x25187fb 0x2518eb6 0x1f2b27e 0x1f2b1bd 0x1f08f22 0x1f086a4 0x1f0857b 0x1a7a913 0x1a7a798 0x358e7c 0x205d 0x1f85)
libc++abi.dylib: terminate called throwing an exception
Again, the login and logout functionality I have implemented is working great, and this was working not too long ago however now it is giving me trouble. Any help would be greatly appreciated. Thanks!
EDIT:
Okay so I added this line of code:
[friendPicker setItemPicturesEnabled:NO];
and it now works however obviously I do not get the little thumbnail profile pictures in the tableview cells.
I guess the error is that it for some reason crashes (SIGABRT) when it is trying to load the profile pictures. If anyone knows why this is that would be great, especially seeing as it worked and loaded the pictures a couple days ago.

Going to add your content to the answer as I came across the same issue and tldr and missed the hack solution.
The stack trace shows an exception being thrown at a line:
[FBGraphObjectTableDataSource tableView:imageForItem:]
Ergo setting:
self.friendPickerController.itemPicturesEnabled = NO;
seems to fix the issue as it won't load images.

Related

Facebook SDK FBLoginView getting EXC_BAD_ACCESS

I'm following the HelloFacebookSample project bundled with the Facebook SDK 3.5. I've virtually copied and pasted everything into my own app, even the stuff from the AppDelegate, yet for some reason clicking the Login button freezes my app. Just for the record, everything authenticates correctly when connecting to the integrated framework in iOS 6, which is done through the FB SDK anyway. It's only when I try to log in using the web, i.e. hit the FBLoginView website opens, get authenticated, return to app. Here is the code in the samepl project, and I'll compare it to mine:
FBLoginView *loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
Mine is a little different:
loginview = [[FBLoginView alloc] init];
loginview.delegate = self;
[self.facebookCell addSubview:loginview];
[loginview sizeToFit];
As for the delegate methods, I've implemented them all verbatim. Why does the app crash? There is no valid reason for a crash when all the code is pretty much identical between my app and the sample app. The debugger doesn't help much even with Zombie Objects on. The actual error is: Thread 1: EXC_BAD_ACCESS (code=2, address=somethingoranother) Anyone got any ideas as to why this is happening?
Regards,
Mike
UPDATE: It appears that the crash happens because something is recurring infinitely on a loop. Seems like over 100,000 processes were put on the main thread by the FB SDK! How?!
UPDATE 2: I'm beginning to think the error is here, even though I copied this straight from the sample AppDelegate.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall *call) {
NSLog(#"In fallback handler");
}];
}
Does this help at all?
I'm having whats seems to be the exact problem, but I have my application sandbox mode already disabled. This app has been working perfectly before, but I just upgraded the SDK and now this happens.
If I have a facebook account configured in iOs, it will work ok, but if not, It will crash.
One thing worth mentioning is if I remove the url scheme, so the app can't go to the web browser or the facebook app, It will user a web view to log in and this works too
EDIT: As far as I'm able to tell, my problem relies in not having access to my application settings in facebook.
The facebook SDK does an [FBUtility fetchAppSettings:callback:] call, more specifically, it does an
https://graph.facebook.com/267496536695242?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name,
which in the case of my app fails with:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
In comparision, any of the examples apps, for example this one, SessionLoginSample
https://graph.facebook.com/380615018626574?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name
returns correctly this:
{
"supports_attribution": true,
"supports_implicit_sdk_logging": true,
"suppress_native_ios_gdp": 0,
"name": "SessionLoginSample",
"id": "380615018626574"
}
Because the SDK expects something it keeps making the same request and gets stuck in a loop until the simulator crashes.
To confirm this, I've manually inserted the expected parameters in the callback, modifyng the facebook sdk, and now everything work perfectly.
It's worth mentioning that I upgraded the SDK from 2.0 which was deprecated, and there was a few parameters in the settings page that were outdated (no client token set, authorization as native/Desktop instead Web, without having the app secret key in the app) but I've already set them alright..
EDIT 2:
This is the method from Facebook SDK (in FBUtility.m) that I've modified. I only added the "bad stuff" if clause.
+ (void)fetchAppSettings:(NSString *)appID
callback:(void (^)(FBFetchedAppSettings *, NSError *))callback {
if (!g_fetchedAppSettingsError && !g_fetchedAppSettings) {
NSString *pingPath = [NSString stringWithFormat:#"%#?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name", appID, nil];
FBRequest *pingRequest = [[[FBRequest alloc] initWithSession:nil graphPath:pingPath] autorelease];
if ([pingRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// Bad stuff
if (error) {
error = nil;
result = [NSDictionary dictionaryWithObjectsAndKeys:#"true", #"supports_attribution",
#"true", #"supports_implicit_sdk_logging",
#"0", #"suppress_native_ios_gdp",
#"Your_App_Display_Name", #"name", nil];
}
if (error) {
g_fetchedAppSettingsError = error;
[g_fetchedAppSettingsError retain];
} else {
g_fetchedAppSettings = [[[FBFetchedAppSettings alloc] init] retain];
if ([result respondsToSelector:#selector(objectForKey:)]) {
g_fetchedAppSettings.serverAppName = [result objectForKey:#"name"];
g_fetchedAppSettings.supportsAttribution = [[result objectForKey:#"supports_attribution"] boolValue];
g_fetchedAppSettings.supportsImplicitSdkLogging = [[result objectForKey:#"supports_implicit_sdk_logging"] boolValue];
g_fetchedAppSettings.suppressNativeGdp = [[result objectForKey:#"suppress_native_ios_gdp"] boolValue];
}
}
[FBUtility callTheFetchAppSettingsCallback:callback];
}
]
);
} else {
[FBUtility callTheFetchAppSettingsCallback:callback];
}
}
Someone found the answer on another thread. In the Facebook Developer centre, the app was set to Sandboxing mode which is what caused this error. Seems it wasn't a problem with the code after all.
Facebook has fixed a server error that was causing this for a lot of developers. However, the server fix only makes the infinite loop problem less likely to happen. It is still there. I created a new bug to track the infinite loop problem.
https://developers.facebook.com/bugs/446010282155033
It's a memory access error, because the loginView is in a __block space.
Just move your controller ( the loginView delegate ) in this zone and it should work.
FBLoginView *loginview = [[FBLoginView alloc] init];
static id staticDelegateInstance = self;
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = staticDelegateInstance;
[self.view addSubview:loginview];
[loginview sizeToFit];

App Crash due to FB sdk 3.2

I am using new FB IOS SDK and app crash and get below error
Assertion failure in -FBCacheIndex
_updateEntryInDatabaseForKey:entry:, /Users/chrisp/src/ios-sdk/src/FBCacheIndex.m Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason: ''
* First throw call stack: (0x334072a3 0x3b0a197f 0x3340715d 0x33cdcb13 0x10b3b1 0x10b635 0x10a7bf 0x3b4b911f 0x3b4b899b 0x3b4b8895
0x3b4c7215 0x3b4c73b9 0x3b4eda11 0x3b4ed8a4)
I have made google and found solution like -lsqlite3.0 in other linker flag and add -lsqlite3 framework, FBsession missing. and i have done all but still i am getting same issue.
My code as below:
in FBClass.m which is NSObject type
-(void) getFriendListForInvitation
{
# try {
if (self.friendPickerController == nil) {
// Create friend picker, and get data loaded into it.
self.friendPickerController = [[FBFriendPickerViewController alloc] init];
self.friendPickerController.title = #"Invite Friends";
self.friendPickerController.delegate = self;
[self.friendPickerController clearSelection];
[self.friendPickerController loadData];
self.friendPickerController.itemPicturesEnabled = TRUE;
}
else{
[self.friendPickerController clearSelection];
[self.friendPickerController updateView];
}
self.friendPickerController.allowsMultipleSelection = FALSE;
// iOS 5.0+ apps should use [UIViewController presentViewController:animated:completion:]
// rather than this deprecated method, but we want our samples to run on iOS 4.x as well.
if([[[UIDevice currentDevice] systemVersion] intValue] >= 5.0)
[[[appdelegate.navigationController viewControllers] lastObject] presentViewController:self.friendPickerController animated:TRUE completion:nil];
else
[[[appdelegate.navigationController viewControllers] lastObject] presentModalViewController:self.friendPickerController animated:YES];
}
#catch (NSException *exception) {
NSLog(#"%#",[exception description]);
}
}
Please help me to solve this issue.....
thanks
Did you manage to solve the issue? I suffer from the same problem.
I determined that this exception is caused by the missing file cache.db in the directory facebook is addressing to. You can check that with the help of the simulator. The directory of the missing simulator file is:
/Users/<user name>/Library/Application Support/iPhone Simulator/6.1/Applications/<app id>/Library/Caches/DataDiskCache
Yet I do not know why the file is missing.
EDIT:
The only thing I came up with was to clear the session data from the app with simple two lines of code:
FBSession.activeSession = nil;
[[NSUserDefaults standardUserDefaults] removeObjectForKey:#"FBAccessTokenInformationKey"];
Unfortunately this solution never actually closes the session but at least it is providing the proper workflow of the app.

Getting error to implement Google+ in iPhone

I am implementing Google+ in Objective-C iPhone using Google+ for iOS tutorials but when I click on sign-in button of Google+ I am getting this error
2013-01-14 14:28:46.168 googleplus_tutorials[2468:11303] GTMMethodCheckMethodChecker: Class WebMIMETypeRegistry does not conform to #protocol(NSObject), so won't be checked
2013-01-14 14:28:46.176 googleplus_tutorials[2468:11303] GTMMethodCheckMethodChecker: Class UIKeyboardCandidateUtilities does not conform to #protocol(NSObject), so won't be checked
2013-01-14 14:28:55.544 googleplus_tutorials[2468:11303] *** Assertion failure in -[GPPSignInButton createGPPSignIn], /Volumes/BuildData/pulse-data/agents/wpyk8.hot/recipes/211255319/base/googlemac/Shared/GooglePlus/Dev/GooglePlusPlatform/GPPSignInButton.m:155
2013-01-14 14:28:55.545 googleplus_tutorials[2468:11303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must specify a client ID for GPPSignInButton.'
*** First throw call stack:
(0x141e012 0x1243e7e 0x141de78 0xcd9f35 0x448c4 0x44688 0x1257705 0x18e920 0x18e8b8 0x24f671 0x24fbcf 0x24ed38 0x1be33f 0x1be552 0x19c3aa 0x18dcf8 0x2301df9 0x2301ad0 0x1393bf5 0x1393962 0x13c4bb6 0x13c3f44 0x13c3e1b 0x23007e3 0x2300668 0x18b65c 0x2e22 0x2d55)
libc++abi.dylib: terminate called throwing an exception
using this link i am implementing google+ in my iphone
https://developers.google.com/+/mobile/ios/getting-started
and this is my code
- (void)viewDidLoad
{
[super viewDidLoad];
static NSString * const kClientId = #"711430132123.apps.googleusercontent.com";
GPPShare *share = [[GPPShare alloc] initWithClientID:kClientId];
signInButton = [[GPPSignInButton alloc]init];
signInButton.delegate = self;
signInButton.clientID = kClientId;
signInButton.scope = [NSArray arrayWithObjects:#"https://www.googleapis.com/auth/plus.moments.write",#"https://www.googleapis.com/auth/plus.me",nil];
AppDelegate *appDelegate = (AppDelegate *)
[[UIApplication sharedApplication] delegate];
appDelegate.signInButton = signInButton;
// Do any additional setup after loading the view, typically from a nib.
}
- (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
// Handle Google+ sign-in button URL.
if ([signInButton handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
return NO;
}
Kindly tell me why I am getting this error.
Have you tried with universalLib(libGooglePlusUniversal.a) of google+? After tracking your crash i think that you have not added the lib in your target.May be it will help you.

twitter ios4 ..Accounts Framework

https://github.com/doubleencore/DETweetComposeViewController
I followed twitter integration here for supporting twitter for both ios5 and ios4.
if ([DETweetComposeViewController canSendTweet]) {
DETweetComposeViewControllerCompletionHandler completionHandler = ^(DETweetComposeViewControllerResult result) {
switch (result) {
case DETweetComposeViewControllerResultCancelled:
NSLog(#"Twitter Result: Cancelled");
break;
case DETweetComposeViewControllerResultDone:
NSLog(#"Twitter Result: Sent");
break;
}
[self dismissModalViewControllerAnimated:YES];
};
DETweetComposeViewController *tcvc = [[[DETweetComposeViewController alloc] init] autorelease];
[tcvc addImage:[UIImage imageNamed:#"YawkeyBusinessDog.jpg"]];
[tcvc addURL:[NSURL URLWithString:#"http://www.DoubleEncore.com/"]];
[tcvc addURL:[NSURL URLWithString:#"http://www.apple.com/ios/features.html#twitter"]];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:tcvc animated:YES];
}
else {
self.oAuth = [[[OAuth alloc] initWithConsumerKey:kDEConsumerKey andConsumerSecret:kDEConsumerSecret] autorelease];
TwitterDialog *td = [[[TwitterDialog alloc] init] autorelease];
td.twitterOAuth = self.oAuth;
td.delegate = self;
td.logindelegate = self;
[td show];
}
The tutorial didn't specify what is self.oAuth so i imported oAuth in my interface file and declared oAuth as a property
I have the following problems now :
1) the code above worked when i didn't put the completion handler block, after adding the handler the build is failing with error in DETweetAccountSelectorViewControllerDelegate in line
#import <Accounts/Accounts.h>
saying no such file or directory exist... which it didn't when there was no completion handler. And yes i have now linked and unlinked to accounts framework more than 5 times now..so it was working before not now.
2) when i run the project without completion handler the twitter dialog pops up. but can't post(authorization request comes up for my twitter app but after authorizing it gets stuck) ..the log in console is
discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:
also if i close the dialog ..the program crashes because there is no code to dimiss the controller which i tried to solve using completion handler.
3) if any one have a simpler tutorial to integrate twitter for both ios4 and ios5 ..can you share..
Thanks
I have recently received the:
discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:
Error in a different twitter framework that I am using.
The solution to the problem was that I had an error in my Delegate Function twitterDidLogin.
I think that if you solve for the error which you have not included on this post, that the 'discarded an uncaught exception' error will go away. Maybe you could paste that error?
I found the answer..there tutorial takes you in the opposite direction..waste my 5 hours on it..
just have to initialize DETweetComposeViewController ..and the rest is taken care of.. in their tutorial.. they show twitter dialog .and can tweet function which will just confuse

TTPostController - Keyboard is not appearing

Hi
I am adding a "post comment section in my iPhone APP"
rest all things are working fine but when I tap on "postController textView" a keyboard is suppose to appear from the bottom but it is not appearing However the cursor is displaying and the text that I am passing using postController.textView.text = #"" is also displaying.
Please suggest the areas to be looked for fixing this bug.
-(void)showCommentView
{
TTPostController *postController = [[TTPostController alloc] init];
// self must implement the TTPostControllerDelegate protocol
postController.delegate = self;
self.popupViewController = postController;
// assuming self to be the current UIViewController
postController.superController = self;
postController.textView.text=#"temporary text";
[postController showInView:self.view animated:YES];
[postController release];
}
above is the code that is giving call to the Three20 PostController
below is the calling method which is unchanged...
-(IBAction)postComment:(id)sender
{
[UserManager instance]authenticateUserAndProceed:self withSelector:#selector(showCommentView)];
}
-(void)showCommentView
{
TTPostController *postController = [[TTPostController alloc] init];
// self must implement the TTPostControllerDelegate protocol
postController.delegate = self;
self.popupViewController = postController;
// assuming self to be the current UIViewController
postController.superController = self;
postController.textView.text=#"temporary text";
[postController showInView:self.view animated:YES];
[postController release];
}
changed method
-(void)authenticateUserAndProceed:(id)parent withSelector:(SEL)selector
{
theParentViewController = parent;
self.theFunctionToCall = selector;
if(userid == nil)
{
GetUserInfoViewController *guivc = [[GetUserInfoViewController alloc] init];
[parent presentModalViewController:guivc animated:YES];
guivc.delegate = self;
[guivc release];
}
else {
//////////////////// below line was replaced///////////
// 2. [theParentViewController performSelector:selector];
// with below code
UIAlertView *alert =[[UIAlertView alloc]initWith Title........
[alert show];
}
}
PROBLEM SUMMARY:
as soon as the user registered, he was not able to the kyboard for the TTPostController
CHANGE SUMMARY:
As soon as the user is registered the call to
[theParentViewController performSelector:selector];
is not sent directly but the call goes to ann alertview which inter calls it.
EFETCS SUMMARY:
the user will see a "you are registered successfully" (kind of) alertview.
tapping OK on which, he will be sent to TTPostController. (this time the keyboard is appearing)
I kept the line# 2 in the AlertViewDelegate method.
I was amazed o see it working just by not calling the line 2 directly.
this worked for me.
I welcome any new and better idea to implement the same