Best practices
Ask for a rating only after people have demonstrated engagement with your app or game.
Avoid interrupting people while they’re performing a task or playing a game.
Avoid pestering people.
Prefer the system-provided prompt.
Weigh the benefits of resetting your summary rating against the potential disadvantage of showing fewer ratings.
For the complete guidance, including worked examples and illustrations, see the canonical page: https://developer.apple.com/design/human-interface-guidelines/ratings-and-reviews