iOS Customize Touch ID Failure? - ios

So I'm attempting to implement touchID in my app, but when I get a mismatch the standard alert for retry pops up. Clicking "Enter Password" does nothing (maybe because I'm on the simulator).
I'm wondering if it's possible to customize the options on that alert, maybe hide "Enter Password" so we can just leave cancel or retry as the only options for this scenario.
Currently I'm only handling success, and am unsure yet how to handle the failure case (i.e. what I can do in the else statement that goes with if success
Documentation seems to be purposely vague on the issue of how to actually handle failures.

Found it through experimentation. LAContext's localizedFallbackTitle holds the answer. It may default to "Enter Password" but setting it to an Empty String hides the button. Wish the documentation would have been more clear on that.

Related

Strange HealthKit Access issue

I'm working on retrieving steps data within HealthKit. The query all works as expected (I'm only retrieving step data) however I'm having a strange issue with the Health Access modal that appears (see screenshot below - this is NOT my app, just an example screenshot taken from the web)
The issue is when the user soft closes the app (i.e. pressing the home to get to springboard) and then goes back into the app. The modal doesn't want to disappear when clicking allow or disallow.
Looking at the log it appears I have this strange error:
Error Domain=com.apple.healthkit Code=5 "(null)"
Any thoughts? If further info is required please let me know.
P.S. Just an addition to this, I notice that when clicking "Don't Allow" (where the "Cancel" is within the screenshot), I get an alert dialogue stating:
"You can turn on health data categories later in the Health app."
Upon clicking "OK" the Health Access screen still does not dismiss.
P.S.S. Not sure if this affect this but when the Health Access screen appears, it does so with the following message in the Log:
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x1343f4040>.

isRegisteredForRemoteNotifications returning NO even after turning on Notifications

So we have a notification screen where users can customize the push notifications they want to receive. In this view controller, we check if [application isRegisteredForRemoteNotifications], we allow users to use the screen, else we show them the prompt that deep links to settings for the app. Now, what's happing is that certain users are complaining that this prompt never disappears even when they turn on in settings. They have sent us the screenshot of the screen, as well as device settings for the app. We have not been able to reproduce this issue. The view controller is directly checking against the OS flag, so there is not much scope of error there. Also we have gone through the code and haven't found anything. I am assuming that because of network issues, deviceToken is not getting delivered to the app. Not really sure what else might be going here. Appreciate any help or suggestions on this matter.

What is the proper way to handle FBSessionStateClosedLoginFailed with iOS FB SDK 3.1.1

When my app needs to e.g. read from a user's facebook, it checks the current state the active FBSession. For the e.g. FBSessionStateOpen, it knows it can just request the information from Facebook, whereas for FBSessionStateCreatedTokenLoaded it must call openWithCompletionHandler. What FBSession method should be called if the current state is FBSessionStateClosedLoginFailed?
That means that a login attempt failed. When this happens for me I - closeAndClearTokenInformation and alert the user that login failed and ask him if he wants to login again.
In short:
In Facebook sample
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/
When such condition occurred, their sample code will call a loginViewController or equivalent.
This is their comments when falling into this condition.
"if the token goes invalid we want to switch right back to the login view, however we do it with a slight delay in order to account for a race between this and the login view dissappearing a moment before "
P.S. I fixed this error my solving Facebook open graph setups and study more on the Scrumptious example such as "return [FBSession.activeSession handleOpenURL:url];" and "[FBSession.activeSession handleDidBecomeActive];"
In long:
This is taken from official FB doc.
http://developers.facebook.com/docs/reference/ios/3.1/class/FBSession#FBSessionState+enum
Given this is the precondition and it has passed other enum states and not a connection error:
"FBSessionStateClosedLoginFailed
Closed session state indicating that a login attempt failed"
It didn't explicitly said the problem. It may be the cached misinformation. Personally and most carefully, I would call '- (void)closeAndClearTokenInformation;", this method would clean up every cache info and show a error message such as "invalid login, please try again" to the client/user.
Then, allow the client the options to do a clean slate login again or skip this process if possible.
HTH

Exit an application or Go to Dash board(main page) programmatically - IOS

I want to exit my application programatically, I googled, some people suggesting to use exit(1), but apple is not supporting that I guess. If it is the case, How do I exit my application programatically. Any helps appreciated.
exit(0); will work but don't use it
You shouldn't force close an app as the standard way to terminate an application is to press the home button (or use the multitasking bar)
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices.
Display an attractive screen that describes the problem and suggests a
correction. A screen provides feedback that reassures users that
there’s nothing wrong with your application. It puts users in control,
letting them decide whether they want to take corrective action and
continue using your application or press the Home button and open a
different application
If only some of your application's features are not working, display
either a screen or an alert when people activate the feature. Display
the alert only when people try to access the feature that isn’t
functioning.
Source
I believe u are not reading the comment properly thus posting the answer for ur question here:
"Simply Don't do that. as apple does not allow application to crash like that."
look at here. How do I exit my iOS app gracefully after handling a Local Notification and here Exit application in iOS 4.0 there are fare discussion over here.
After the release of iOS4, multitasking(new feature) was added by APPLE. This feature enabled the users to keep the app into suspended state in the background if in between he has to do some other activity(e.g. picking up phone call). So Apple considers your app should be maintained in the background until the user deletes the application from the background. And after this if you want to exit use exit(0);, using this would further lead to rejection from AppStore
Here's a wrong way to accomplished exit function in your app. This is coming to mind when I read your question, never applied anywhere, so be careful if you'll gonna implement this!
- (void) exitApp
{
NSArray *array = [[[NSArray alloc] init] autorelease];
NSLog(#"%#",[array objectAtIndex:10]); //will crash here, looks like exit.
}
P.S. You can put this code inside your UIAlertView asking exit confirmation like Do you really want to exit?. In YES button pressed you can call [self exitApp]; User think that he'll exit from the app.

Wrong Twitter result after unsuccessful send attempt

When using TWTweetComposeViewController in IOS5 to compose and send a Tweet, if the Tweet is a duplicate, an error alert is shown saying that the Tweet is duplicate and cannot be sent, but the TWTweetComposeViewControllerCompletionHandler still gets a result value of TWTweetComposeViewControllerResultDone rather than TWTweetComposeViewControllerResultCancelled.
(This may happen in other cases as well, not just for duplicate tweets - I didn't check).
This makes it impossible to show a confirmation message to the user after a successful send, because the handler gets the same "Done" result whether the send was successful or not.
Is there another way to check whether the send was actually successful?
The documentation for TWTweetComposeViewController's completionHandler states the following:
The handler has a single parameter that indicates whether the user finished or cancelled composing the tweet.
The completionhandler tells you whether the user actually finished or cancelled composing the tweet herself, regardless of the result of actually posting the tweet.
Update
I've looked a bit further into this and it seems like the TWTweetComposeViewController is one of those convenience classes that take away most of the work for the developer in exchange for not letting the developer handle anything by himself. In this case, the developer has no way of handling the errors that occur when sending the tweet and has to rely on the iOS provided alert dialogs to inform the user instead.
You can hack around this by using Saleh's method, though I don't consider that safe enough to use in an actual app. See the comments in his answer.
Another method is by implementing your own view controller which handles tweet composition and sending. You can do this by following the procedure in the following stackoverflow answer.
Check for the alert message, if the alert message is shown you'll be able to know that the error occurred. I think that the alert message gets added in the window. You can check the count of window's subviews, if they get increased when delegate function is called, you'll know that the error occurred.
Isn't it only a view controller? The result of the view controller is fine as it states what happened with the view controller ( it is done running ).
With what are you sending your tweet? That library most likely has some stuff implemented you can use to determine whether your tweet was sent successfully or not.
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if([urlResponse statusCode]==200)
{
//Tweet tweeted successfully....
}
}
this might help you .
In respponse if url response code is 200 you can say text is tweeted....

Resources