App Crashes After Facebook Login - iphone

i made an iphone App which I've submitted in the App store . The App is there in the App Store for about an year . It has basically a faceBook Login button . One fine day it crashes, the moment i click my Facebook login Button in my iPhone 4, iPhone 4s.When i try to run it in my Macbookpro it also crashed . I'm getting the error
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull lowercaseString]: unrecognized selector sent to instance 0x2125ce8'".........
It works fine in my iPhone 3Gs...please help me .How can a iPhone App crash After working fine for about an year. Is it something related to Facebook updated methods or related to iPhone version.The App crashes exactly after FBrequest is called !please help me I'm losing my reputation .......

Looks like there is a string in your app that is set to point to NSNull. The app crashes when you are attempting to make that string lowercase.
Since NSNull points to a static object of type NSNull, trying to send the message "lowercaseString" to it causes the app to crash. (if it had been nil, Objective-C would simply ignore the message)
Could it be that there is a string somewhere that used to be set to a value, but for some reason now has been removed and is set to NSNull? It could be due to changes in the FaceBook-API but it could also be caused by changes in what the server is sending to you, different information in your facebook account and many other things. The parser you are using may be setting NSNull instead of nil whenever a NULL-value is sent by the server.
Bare in mind that it might also not be related to Facebook at all, since you find different behaviour on iPhone3GS.
You could try to look around for NSString values in your code that you are trying to make lowercase. Use the debugger to try to identify strings that are of type NSNull. You can compare your strings to NSNull like this:
if (text == (id)[NSNull null]) {
// String is NSNull!
}

Related

App terminates on run

I am making an app in Swift and Xcode 6 and everything has been working fine, until now. When I go to run it, I get a delegate error and it crashes immediately. Here is the debugger code:
2014-11-11 10:18:48.282 Pro Cast[2987:65789] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'You have to call setApplicationId:clientKey: on Parse to configure Parse.'
I've never had an issue with Parse up tot his point. What can I do?
You need to set your Parse applicationID and clientID in the AppDelegate.m. Specifically in didFinishLaunchingWithOptions You can get your appID and clientID on the parse website.
Don't forget to import the parse framework.

Having trouble getting facebook sample to work - the one called "Feed Dialog".

Does anyone have a working xcode project they could upload / share?
I'm having trouble getting this to work clean without errors.
The example is located here.
[https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/][1]
I have the project working to this extent -
The main viewcontroller is displayed with a button that allows the user to send a post to facebook.
When clicked, facebook indicates that the user has already authorized the app to post to their page. He clicks OK on the facebook message and then the user sees the 'share' dialog and is allowed to enter text for his post.
As the sharedialog is presented to the user, I get this warning in my console
2012-09-29 11:04:25.190 gw_fakeapp[8016:fe03] FBConditionalLog: handleOpenURL should not be called once a session has closed
My problem comes when the user clicks "share", I get the error:
2012-09-29 11:04:32.217 gw_fakeapp[8016:fe03] *** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: an attempt was made reauthorize permissions on an unopened session'
*** First throw call stack:
(0x14c9022 0xfe2cd6 0x14c8ee1 0x171d1 0x14367 0x3ad8 0x14cae99 0x14814e 0x386a0e 0x14cae99 0x14814e 0x1480e6 0x1eeade 0x1eefa7 0x1ee266 0x16d3c0 0x16d5e6 0x153dc4 0x147634 0x1da9ef5 0x149d195 0x1401ff2 0x14008da 0x13ffd84 0x13ffc9b 0x1da87d8 0x1da888a 0x145626 0x28ed 0x2815)
terminate called throwing an exception(lldb)
Does anyone have a working project I could compare mine with?
Thank you!
Phil
You can download sample of codes from developer.apple.com which describe about Facebook post publishing.
Here is the link: https://github.com/downloads/facebook/facebook-ios-sdk/FacebookSDK-3.1.pkg

iPhone app crashes when asking for Location Services permission

My app has a button, which, when tapped, gets the phone's current location and appends the CLLocation object's timestamp (NSString) to another string.
the first time the user uses the app and calls this method, the app crashes:
'NSInvalidArgumentException', reason: '* -[__NSCFConstantString sringByAppendingString:]: nil argument'
which I can understand, because the app doesn't have permission to use Location services yet and the timestamp is still nil.
At same time, after the app has crashed, the user is asked for permission, and this problem disappears once the user gives the app permission to use Location services.
How can I stop the app from crashing the first time ?
i've tried to get the current Location in viewWillLoad if [locationManager authorizationStatus] != authorised, but the notification asking for permission only appears instantly.
Thanks for helping !!
To make sure you are using a nil when there is risk of raising an exception you can check for nullity very simply:
if(stringToAppend) {
// Do something with the string
}
That way if the object is nil, the risky code won't be executed and the app won't crash.

CocoaSoundCloudAPI crashes when I connect to company FaceBook account. Fix required

(I've previously tried SoundCloud GoogleGroups (defunct?), and directly to my SoundCloud contact for this. Told to post the issue here.)
Just trying to get to grips with SoundCloudAPI on iOS and I found a nasty error. Either this is a bug in the API, or a bug in SoundCloud, or (most likely) I'm doing something wrong. :) But the end result would be a broken app, so I'm keen to understand what is going wrong here.
I set up a new iOS project, following the Tobias video, and the CocoaSoundCloudAPI readme.
Using theSCShareViewController I connect to a test SoundCloud account I made for my company. I then create a new connection within the app to a test company FaceBook account. I click install, and Allow All permissions.
The app then hangs, with Terminating app due to uncaught exception 'NSInvalidArgumentException'
on the line (in SCRecordingSaveViewController.m) :
cell.textLabel.text = [connection objectForKey:#"display_name"];
Whenever I run the app now, it crashes on this line.
When I dump out the contents of the connection NSDictionary, it looks like there are two connections listed in self.availableConnections, a "facebook_page" connection with the display_name I gave for my company FaceBook page. But also a second "facebook_profile" with a null display_name. It's this second connection that is causing the API to crash. Presumably the API developers were never expecting a null display_name, but also I don't understand why it's listing two FaceBook connections at all.
If I investigate the value of "display_name" further then Xcode tells me "Variable is not a CFString" and indeed if I look at the class then it is not.
Going into SoundCloud in a browser, I can list the connections, and it shows two of them. One with the name of my company FB account, and a second one:
"http://facebook.com/profile.php?id=***** is your primary Facebook user account"
If I disconnect both of these I can use the SoundCloudAPI again without it crashing.
I then created new personal test SoundCloud and FaceBook accounts, and did the same thing again within the app. This time it did not crash (and in fact worked great), and the connection NSDictionary has one connection "facebook_profile" with a valid display_name. SoundCloud via a browser also lists just one connection.
Note that this also happens with CocoaSoundCloudDemo with no code changes.
I can also hack around with the code to avoid crashing when connecting to my company account:-
// cell.textLabel.text = [connection objectForKey:#"display_name"];
id displayName = [connection objectForKey:#"display_name"];
if ([displayName isKindOfClass:[NSString class]])
{
cell.textLabel.text = (NSString*)displayName;
}
...which gives me two rows with FB connections, but the second is blank. With some effort I can work out what they are doing here in the code, and not show a row if the display_name is invalid, but obviously I'd rather not have to do that and use the standard API code.
SO, long story short:-
1) Does SoundCloud allow you to connect to a company FaceBook account? Is there some special setup you need to do on that FaceBook account so that SoundCloud only sees the "Facebook_profile" and not also "Facebook_page"? The problem seems to be within SoundCloud itself, and not the iOS API, but it is the API that crashes.
2) From my test app, if a user tries to connect a SoundCloud account to a company FaceBook account (at least, with the minimal setup that I have in mine), then the SoundCloudAPI will crash with an exception, and my entire app will continue to crash until the user logs on with a browser to SoundCloud and removes the two connections manually. Surely this can't be good, but I've Googled for anyone with a similar issue and found nothing. Without finding a fix for this I can't use the full API in my app for fear my users will hit the same crash bug, and perhaps will have to create a cut-down custom UI that avoids the need to share to FaceBook etc.
sorry that we have not come back to you earlier.
It is always good to receive feedback from our SDK users and yes we should check
against nil values and handle this case accordingly.
However, I investigated the situation you are describing and actually it worked
flawlessly for me. Two rows for Facebook were displayed properly as soon as I
connected my SoundCloud account w/ the new Facebook page in my SoundCloud profile settings.
You can also check which accounts are connected by running
curl "https://api.soundcloud.com/me/connections.json?oauth_token=<YOUR_OAUTH_TOKEN>
In my case I received something like this
{
"kind": "connection",
"id": 12345678,
"created_at": "2013/01/10 15:55:20 +0000",
"display_name": "Testpage",
"post_publish": true,
"post_favorite": true,
"type": "facebook_page",
"service": "facebook_page",
"uri": "https://api.soundcloud.com/connections/12345678"
},
{
"kind": "connection",
"id": 12345679,
"created_at": "2013/01/10 11:07:56 +0000",
"display_name": "Rob",
"post_publish": true,
"post_favorite": true,
"type": "facebook_profile",
"service": "facebook_profile",
"uri": "https://api.soundcloud.com/connections/12345679"
}
So while uploading a new sound via the SDK, I got two Facebook rows in
the sharing section. Are you still experiencing this issue?
We will release an update to our iOS SDK soon, so stay tuned and thanks for your feedback.

Authlogic and iPhone app login

This has been a head-banger for me. I have looked at all of the similar questions on SO and none have proved satisfactory. Here's my go at it.
I have a perfectly fine rails 3 app setup with Authlogic.
I have been using Objective Resource (http://iphoneonrails.com/) to connect my iPhone app and my Rails app, and it has been working fine.
Now is the time to add authentication, and I cannot figure it out.
I have a UserSession class in my iPhone project with a username and password field. When the app launches, I present a login screen with username and password fields. Upon clicking a button, the iPhone app attempts to create the UserSession.
I took my code for doing that from http://www.corprew.org/blog/2010/01/27/authlogic-and-objectiveresource/
us.username = usernameField.text;
us.password = passwordField.text;
NSError * err = nil;
if(![us saveRemoteWithResponse:&err])
{
NSLog(#"%d", err);
NSLog(#"whoops, error");
}
When I run that code, the Log shows "0" and "whoops, error" meaning that the UserSession did not save. This occurs for both correct and incorrect logins.
Additionally, I have placed token comments in saveRemote ("I'm in saveRemote" etc.) and those never appear in my log.
Any ideas here?
If you want me to post anymore code, let me know. I will be up all night with this one.
Question resolved.
Don't use ObjectiveResource :-)
Switched to ASIHTTP and it's working fine for my needs right now.