react-native-sensitive-info: [IOS] Protected data not available yet. Retry operation

We started to get a lot of Protected data not available yet. Retry operation from our ios users.

It is happening for ios users above 14.6 while the majority of the problems come from ios 15.x. Does anyone know what could be causing the problem? We’re on 6.0.0-alpha.9

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

@sourabhdadapure i found this in the code https://github.com/mCodex/react-native-sensitive-info/blob/495dd7f08c077f5744e56803e45f54787df3dab3/ios/RNSensitiveInfo/RNSensitiveInfo.m#L261 and that made me think of catching the error and just retrying to get the data. It’s not the cleanest solution but it does work for now:

let getDataAttempts = 0;

const getUserData = async () => {
  try {
    const refreshToken = await SInfo.getItem('refreshToken', {});
  } catch (e) {
    if (e.code === 'protected_data_unavailable') {
      if (getDataAttempts < 10) {
        // Retry getting item after 300ms for max 10 attempts.
        setTimeout(() => {
          getUserData();
        }, 300);
      } else {
        // Do something after 10 failed attempts, like logging out.
      }

      getDataAttempts++;
    }
  }
};

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Not really, we reduced our number of concurrent async operations which reduced the occurrences. But they still occur.