Search code examples
iospush-notificationgame-centergamekit

Is it possible to issue an alert when a GameKit opponent is ready?


I made a game using GameKit and I am using the framework to manage a real-time match between two opponents. If I invite a specific person to a match, or make sure they are "waiting for opponent" at the same time as me, the match and game goes smoothly and everything is great.

The problem I have now is that there aren't a lot of people on my app yet, and so people that are wanting to play against a random opponent who also wants to play, don't have any way of knowing when a match could be ready.

Is there a way to utilize GameKit, but enhance the experience so that a push notification or alert of some kind is sent when an opponent is found? It could be this is all built in, but I'm not seeing anything.


Solution

  • AFAIK, GameKit does not support push-notifications for matching real-time games while your App isn't running.

    But, GameKit has a Player Activity API that tells you how many matches were requested in the last 60 seconds, and you could use that number to create an informative message or status to show the player.

    EDIT: the methods in question are

    - queryActivityWithCompletionHandler:
    - queryPlayerGroupActivity:withCompletionHandler: