It isn't the only way. But going through the Island Challenge is the most certain way. The key to your success is to pass the Grand Trial of each of the Island's Kahunas.
I will answer that with great pleasure. A Grand Trial is a battle between trainer and Island Kahuna. If the trainer wins, the Kahuna acknowledges that trainer's worthiness.
But young Ash, are you interested in learning why the Island Challenge was started so many years ago? [Pikachu is seen playing with Hala's Hariyama by Pikachu running around Hariyama's belly] You see, it wasn't simply made to make trainers stronger in battle, it was to raise young people in such a way that they will love and protect the islands of Alola, as well as the many people and Pokémon who inhabit them. [It's tempting to battle but sometimes violence can't always solve problems. There are alternate methods.]