SystangoTechnologies / react-native-apple-authentication

React Native apple sign in
MIT License
42 stars 25 forks source link

[iOS] I got an error "Apple sign in only support iOS 13 or newer" #1

Closed khuongphp closed 4 years ago

khuongphp commented 5 years ago

Screenshot_2

As in this description 1. Sign in with Apple is supportable from XCode 11 and iOS 13. Although you can install XCode 11 on Mac Mojave 10.14.14 and later. I think we need some check in this function like this


-(NSDictionary *)constantsToExport
{
    if (@available(iOS 13.0, *)) { // <=== add this
        NSDictionary* scopes = @{@"FULL_NAME": ASAuthorizationScopeFullName, @"EMAIL": ASAuthorizationScopeEmail};
        NSDictionary* operations = @{
            @"LOGIN": ASAuthorizationOperationLogin,
            @"REFRESH": ASAuthorizationOperationRefresh,
            @"LOGOUT": ASAuthorizationOperationLogout,
            @"IMPLICIT": ASAuthorizationOperationImplicit
        };
        NSDictionary* credentialStates = @{
            @"AUTHORIZED": @(ASAuthorizationAppleIDProviderCredentialAuthorized),
            @"REVOKED": @(ASAuthorizationAppleIDProviderCredentialRevoked),
            @"NOT_FOUND": @(ASAuthorizationAppleIDProviderCredentialNotFound),
        };
        NSDictionary* userDetectionStatuses = @{
            @"LIKELY_REAL": @(ASUserDetectionStatusLikelyReal),
            @"UNKNOWN": @(ASUserDetectionStatusUnknown),
            @"UNSUPPORTED": @(ASUserDetectionStatusUnsupported),
        };

        return @{
            @"Scope": scopes,
            @"Operation": operations,
            @"CredentialState": credentialStates,
            @"UserDetectionStatus": userDetectionStatuses
        };
    } else {// <== previous version
        // Fallback on earlier versions
        return @{};
    }
}
akshit5230 commented 4 years ago

Please add a check when you display the sign in button. Only display it if the device has iOS 13 or above:

` renderAppleSigninButton = () => {

const majorVersionIOS = parseInt(Platform.Version, 10);
console.log('ios version is', majorVersionIOS)
if (majorVersionIOS <= 12) {
  return null
}

return (
  <View>
    <View>
      <Text style={styles.ortext}>OR</Text>
    </View>
    <View style={{
      justifyContent: 'center',
      alignItems: 'center',
      marginTop: 20
    }}>
      {SignInWithAppleButton(styles.appleBtn, this.appleSignIn)}
    </View>
  </View>
)

} `