Apple reported strong iPhone sales, with smartphone revenue rising more than a fifth, defying a broader downturn in the smartphone market where rivals are struggling.