title: isProtectedDataAvailable is returning true always in iOS
body: <h1>Problem</h1>
  
  <p><code>isProtectedDataAvailable</code> is true but <code>applicationProtectedDataDidBecomeAvailable</code> is getting called after 10~20 seconds in iOS which means <code>isProtectedDataAvailable</code> was supposed to be false before that callback is called.</p>
  
  <hr>
  
  <p>I am working on <code>iOS</code> app built in <code>Objective C</code>. I have enabled <a href="https://developer.apple.com/documentation/foundation/nsfileprotectiontype?language=objc" rel="noreferrer">data protection</a> (currently configured for  <a href="https://developer.apple.com/documentation/foundation/nsfileprotectioncompleteuntilfirstuserauthentication?language=objc" rel="noreferrer">FirstUserAuthentication</a>) for my app from AppStore profiles as well as from xcode plist .</p>
  
  <p>Our database is becoming inaccessible for few seconds after device reboot and first unlock due to Apple's <a href="https://www.apple.com/business/docs/site/iOS_Security_Guide.pdf" rel="noreferrer">Data Protection</a> policy. So I am restricting any database operations with below logic when app getting launched.</p>
  
  <pre><code>if([[UIApplication sharedApplication] isProtectedDataAvailable]) {
      //access data
  }else {
      // wait for applicationProtectedDataDidBecomeAvailable callback
  }
  </code></pre>
  
  <p>I found some unexpected behavior. Even though <code>[[UIApplication sharedApplication] isProtectedDataAvailable]</code> is returning <strong>true</strong>, after <code>10~20</code> seconds (<a href="https://stackoverflow.com/a/7515941/1084174">grace period</a>) <code>applicationProtectedDataDidBecomeAvailable</code> callback is called as part of this from my above code logic, the database is accessed and failed due to actually still being protected by OS. </p>
  
  <p>Is there anything I am missing? Why does <code>iOS</code> returning <code>[[UIApplication sharedApplication] isProtectedDataAvailable]</code> value as true when actually protected data are not yet available?</p>
  
  <p>I am working on, Xcode 11.0, tested device OS 13.2.</p>
  
  <h3>Update</h3>
  
  <p>For some cases in log I found the <code>[[UIApplication sharedApplication] isProtectedDataAvailable]</code> is returning 1 but NSUserDefault still inaccessible. What can be possible reason?</p>
  
  <hr>
  
  <p><sup>
  <strong>isProtectedDataAvailable</strong> - The value of this property is false if data protection is enabled and the device is currently locked. The value of this property is set to true if the device is unlocked or if content protection is not enabled. When the value of this property is false, files that were assigned the complete or completeUnlessOpen protection key cannot be read or written by your app. The user must unlock the device before your app can access them.
  </sup>
  <sup>
  <strong>NSFileProtectionCompleteUntilFirstUserAuthentication</strong> - After the user unlocks the device for the first time, your app can access the file and continue to access it even if the user subsequently locks the device.
  </sup></p>