Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's an is an idea to workaround this issue:</p> <p>No matter if a "GC authenticateWithCompletionHandler"-Request is cancelled </p> <ul> <li>by the user tapping "Cancel" in the dialog </li> </ul> <p>or due to the fact that </p> <ul> <li>GC is disabled on the device (which happens after the user has cancelled the alert-dialog exactly 3 times (in iOS 5 at least)) </li> </ul> <p>you will always receive an NSError with code 2 saying "The requested operation has been cancelled.". </p> <p>The only differentiator that i could find is the time passed between the authenticateWithCompletionHandler-Request and the the execution of the completion-Handler.</p> <p>So when sending the request i am saving the time:</p> <pre><code>requestTime = [NSDate date]; </code></pre> <p>and in my completion handler i measure the time lapsed:</p> <pre><code>NSDate* now = [NSDate date]; CFTimeInterval elapsedTimeSinceAuthenticationRequest = [now timeIntervalSinceDate:requestTime]; NSLog(@"time Elapsed: %f", elapsedTimeSinceAuthenticationRequest); </code></pre> <p>If the user cancelled the request, the time passed will be significantly longer compared to the time passed if GC cancelled the operation. In my tests, it took a user at least one second to cancel the dialog, whereas a GC-cancelled request took less than 0.1 seconds (on my iPhone 4)</p> <p>Of course, these values may vary depending on the device the code runs on and on what else the processor is busy with at the moment. One pitfall i already examined is the application launch: If you are sending the authenticationRequest during applicationDidFinishLaunching as suggested by Apple, it took much longer for GC to cancel the request in my case, because the device is busy loading views and whatever is necessary to launch the app.</p> <p>So let me know if you tried this solution and if it worked for you, as will i once i have done further testing...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload