South Africa has withdrawn a controversial asylum directive that sparked widespread protests in the country.