what’s new in game center - apple developer · • stored in users icloud • follows cloud kit...

120
© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Graphics and Games #WWDC16 Session 611 What’s New in Game Center Megan Gardner Software Engineer

Upload: others

Post on 11-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Graphics and Games #WWDC16

Session 611

What’s New in Game Center

Megan Gardner Software Engineer

Page 2: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center

Social gaming networkLeaderboardsAchievementsChallengesMultiplayeriOS, macOS, tvOS, and watchOS

Page 3: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

New in Game Center

New way of sending multiplayer invites

Page 4: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

New in Game Center

New way of sending multiplayer invitesBig news for the Game Center app

Page 5: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

New in Game Center

New way of sending multiplayer invitesBig news for the Game Center appNew API: Persistent Game Sessions

Page 6: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

New in Game Center

New way of sending multiplayer invitesBig news for the Game Center appNew API: Persistent Game SessionsApple Watch support

Page 7: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

New in Game Center

New way of sending multiplayer invitesBig news for the Game Center appNew API: Persistent Game SessionsApple Watch support

Game Technologies for Apple Watch Mission Friday 3:00PM

Page 8: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Play with anyone you can messageMessages-Based Multiplayer Invites

Page 9: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Current stateGame Center Multiplayer

GKMatchmakerViewController• Built-in UI• Invite friends• Play now (automatch)

GKMatchmaker• Programmatic API• Create and process invites

Page 10: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Messages-Based Invites

New integrated Messages View Controller• Built into GKMatchmakerViewController• No code changes required

Invite anybody• Send invites via Messages and iCloud

NEW

Page 11: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Generates Rich LinkBased on iCloud

Page 12: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Generates Rich LinkBased on iCloud

Page 13: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Player selects invitees• Contacts• Game Center friends• Nearby

Page 14: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Player selects invitees• Contacts• Game Center friends• Nearby

Page 15: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Player selects invitees• Contacts• Game Center friends• Nearby

Page 16: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Send Message• Can add additional text• Sends to all players• Game Center accounts get a notification

Page 17: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Send Message• Can add additional text• Sends to all players• Game Center accounts get a notification

Page 18: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Invitee accepts• Taps the link to accept• Takes into the game

- Or App Store if game is not installed

Page 19: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Invitee accepts• Taps the link to accept• Takes into the game

- Or App Store if game is not installed

Page 20: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Built-in UIMessages-Based Invites

Invitee accepts• Taps the link to accept• Takes into the game

- Or App Store if game is not installed

Page 21: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Rich link imageMessages-Based Invites

Shown with inviteFilename: GKMessageInvite.pngHeight and Width:150px - 960px

Page 22: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center Friends

Friends list frozen• No longer a prerequisite for multiplayer• Friends visible in Recent Players tab

GKFriendRequestComposeViewController deprecated• Allowed apps to present UI to send friend requests• Rarely seen

Page 23: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center App

Page 24: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center App

Manage accountManage friendsBrowse games listBrowse leaderboardsView achievementsView challengesView turns

Page 25: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center App

Manage accountManage friendsBrowse games listBrowse leaderboardsView achievementsView challengesView turns

Page 26: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center App

Manage accountManage friendsBrowse games listBrowse leaderboardsView achievementsView challengesView turns

Page 27: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Manage account Settings

Manage friends Settings

Browse games App Store

View leaderboards GKGameCenterViewController

View achievements GKGameCenterViewController

Send and view challenges GKGameCenterViewController

View and take turns GKTurnBasedMatchmakerViewController

Game Center in iOS

Page 28: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

A brand new way to multiplayGame Sessions

Page 29: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Center Multiplayer

Real-time• Connects 2-4 players• Requires all players to keep running app• Peer-to-peer connections for duration of match

Turn-based• Connects 2-16 players• Formal passing of turns among players• Games stored by Game Center until aged out

Page 30: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

iCloud-based multiplayerGame Sessions

Generalized interface for saving and sharing game dataEasily sharable instancesFlexible game structureReal time session streamsPlay with anyone

Page 31: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Data and PlayerGame Sessions

Page 32: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Data and PlayerGame Sessions

Game Data

Page 33: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Data and PlayerGame Sessions

Player1

Game Data

Page 34: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Multiple playersGame Sessions

Player1

Player2

Player3

Player4

Game Data

Page 35: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player3

Message passingGame Sessions

Player1

Player2

Player4

Game Data

Page 36: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player3

Message passingGame Sessions

Player1

Player2

Player4

Game Data

Page 37: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player3

Message passingGame Sessions

Player1

Player2

Player4

Game Data

Page 38: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player3

Message passingGame Sessions

Player1

Player2

Player4

Game Data

Page 39: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player4

BadgingGame Sessions

Player1

Game Data

Page 40: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player4

BadgingGame Sessions

1

1

Player1

Game Data

Page 41: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Many playersGame Sessions

Player 6

Player 16

Player 11

Player 1

Player 2

Player 3

Player 4 Player

5

Player 7

Player 8

Player 9

Player 10

Player 12Player

13Player

14

Player 15

Player 17

Player 18

Player 100

Game Data

Player2

Player3

Player4

Player1

Page 42: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Many playersGame Sessions

Player 6

Player 16

Player 11

Player 1

Player 2

Player 3

Player 4 Player

5

Player 7

Player 8

Player 9

Player 10

Player 12Player

13Player

14

Player 15

Player 17

Player 18

Player 100

Game Data

Player2

Player3

Player4

Player1

Page 43: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Many sessionsGame Sessions

Page 44: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player1

Real-time streamsGame Sessions

Game Data

Player4

Page 45: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player1

Real-time streamsGame Sessions

Game Data

Player4

Page 46: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player1

Real-time streamsGame Sessions

Game Data

Player4

Page 47: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Player2

Player3

Player1

Real-time streamsGame Sessions

Game Data

Player4

Page 48: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Classes

GKGameSession• Interact with session data

GKCloudPlayer• Player in a GKGameSession

GKEventListener• Notify when events happen on a session

GKGameSessionError• Errors we can get from sessions

Page 49: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

GKGameSession

Page 50: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

API overviewGKGameSession

Create a session, delete a session, get session listLoad game data, store game data, resolve conflictsShare session, add players, remove players, get player listSend notification messages, set and clear badgesJoin real-time stream, leave streamSend and receive data within stream

Page 51: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

DetailsGKGameSession

Game data• Store up to 512KB game data• Stored in users iCloud• Follows Cloud Kit conventions

Messages and Badges• Game Center Notifications• Badging controlled by developer

Real-time streams• Leverages Apple infrastructure

Page 52: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

What you’ll needCreating a Session

Title• Name for the session

Container ID• Allows sharing session among multiple games

Max streaming players• Up to 16

+ (void)createSessionInContainer:(NSString *)containerName withTitle:(NSString *)title

maxConnectedPlayers:(NSInteger)maxPlayers completionHandler:(void(^)(GKGameSession *session,

NSError *error))completionHandler;

Player1

Game Data

Page 53: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Any player in session can access game dataMetadata also provided• Last modified date• Last modified player

// Load game data

- (void)loadDataWithCompletionHandler:(void(^)(NSData *data, NSError

*error))completionHandler;

Player1

Game Data

Page 54: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Simple method for storing data• Up to 512KB

// Save game data

- (void)saveData:(NSData *)data completionHandler:

(void(^)(NSData *conflictingData, NSError *error))completionHandler;

Player1

Game Data

Page 55: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Simple method for storing data• Up to 512KB

// Event Listener

- (void)session:(GKGameSession *)session

player:(GKCloudPlayer *)player

didSaveData:(NSData *)data;

Player1

Game Data

Page 56: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Save conflicts may occur• App must resolve and resave• Possible for resolved data to still be

conflicted• Continue to resolve, and attempt to resave

until no error is returned

Player1

Game Data

Player 2

Player 3

Page 57: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Save conflicts may occur• App must resolve and resave• Possible for resolved data to still be

conflicted• Continue to resolve, and attempt to resave

until no error is returned

Player1

Game Data

Player 2

Player 3

Player 2

Player 3

Page 58: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Save conflicts may occur• App must resolve and resave• Possible for resolved data to still be

conflicted• Continue to resolve, and attempt to resave

until no error is returned

Player1

Game Data

Player 2

Player 3

Player 3

Page 59: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading and savingSession Data

Save conflicts may occur• App must resolve and resave• Possible for resolved data to still be

conflicted• Continue to resolve, and attempt to resave

until no error is returned

Player1

Game Data

Player 2

Player 3

Page 60: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Adding a playerSharing a Session

Any player can invite other players to join a sessionProvided via unique session “URL”Send via iMessage, Email, TwitterRecipient joins session by tapping link

Player1

Game Data

Page 61: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Adding a playerSharing a Session

Player1

Game Data

Page 62: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Adding a playerSharing a Session

Player1

Game Data

Hey, want to play?http://www.icloud.com/URL

iMessage

To: Player 2

Page 63: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Adding a playerSharing a Session

Player1

Game Data

Player2

Hey, want to play?http://www.icloud.com/URL

iMessage

To: Player 2

Page 64: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

// Sharing a Session

// Get URL for this session

- (void)getShareURLWithCompletionHandler:(void(^)(NSURL *url, NSError

*error))completionHandler;

// Event Listener - (void)session:(GKGameSession *)session didAddPlayer:(GKCloudPlayer *)player;

Page 65: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

GKCloudPlayer

Each player is a GKCloudPlayer• PlayerID unique to app container• DisplayName

Not a GKPlayer object• Only for use with GKGameSessions• Not for GKScore, GKAchievement…

Player

Game Data

Player 2

Page 66: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Getting Cloud Players

Get current player• See who owns the session

Get players in session• Send messages and set badges

// Player Signed into iCloud on device + (void)getCurrentSignedInPlayer:(void(^)(GKCloudPlayer *player, NSError *error))handler;

// Players current in Session @property (nonatomic, readonly) NSArray<GKCloudPlayer *> *players;

Page 67: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Messages and Badges

Page 68: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

OverviewSending and Receiving Messages

Messages arrive as Game Center NotificationsAll players can send messages at any timeMessages are localizableCan send relevant dataOptional badging for message recipients

Page 69: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

// Sending Messages

- (void)sendMessageWithLocalizedFormatKey:(NSString *)key

arguments:(NSArray<NSString *> *)arguments

data:(NSData *)data

toPlayers:(NSArray<GKCloudPlayer *> *)players

badgePlayers:(BOOL)badgePlayers

completionHandler:(void(^)(NSError *error))completionHandler;

// Event Listener on Receiving side

- (void)session:(GKGameSession *)session didReceiveMessage:(NSString *)message withData:

(NSData *)data fromPlayer:(GKCloudPlayer *)player;

Page 70: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Badges

Badge may be included with messageOne badge increment per sessionApp icon will show overall tally

// Clear badges programmatically

- (void)clearBadgeForPlayers:(NSArray<GKCloudPlayer *> *)players completionHandler:(void(^)

(NSError *error))completionHandler;

Page 71: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Managing Sessions

Page 72: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Loading Sessions

Load all sessions local player is a part of

+ (void)loadSessionsInContainer:(NSString *)containerName completionHandler:(void(^)

(NSArray<GKGameSession *> *sessions, NSError *error))completionHandler;

Load the data and players for a specific session

+ (void)loadSessionWithIdentifier:(NSString *)identifier completionHandler:(void(^)

(GKGameSession *session, NSError *error))completionHandler;

Page 73: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Deleting a Session

Removes player from a session they do not ownDeletes session data if originating player

+ (void)removeSessionWithIdentifier:(NSString *)identifier completionHandler:(void(^)

(NSError *error))completionHandler;

Event Listener- (void)session:(GKGameSession *)session didRemovePlayer:(GKCloudPlayer *)player;

Page 74: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Session Streams

Page 75: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

OverviewGame Session Streams

Connect to current playersSee status of players in connectionSend data to all players in connectionAdd and drop players without restarting connection

Page 76: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Connection State

Setting state automatically creates connectionsWill fail if max players has already been reached

- (void)setConnectionState:(GKConnectionState)state completionHandler:(void(^)(NSError

*error))completionHandler;

Show players with specific state

- (NSArray<GKCloudPlayer *> *)playersWithConnectionState:(GKConnectionState)state;

Event Listener

- (void)session:(GKGameSession *)session player:(GKCloudPlayer *)player

didChangeConnectionState:(GKConnectionState)newState;

Page 77: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Sending Stream Data

Data sent to all connected playersReliable or unreliable transport

- (void)sendData:(NSData *)data withTransportType:(GKTransportType)transport

completionHandler:(void(^)(NSError *error))completionHandler;

Event Listener

- (void)session:(GKGameSession *)session didReceiveData:(NSData *)data fromPlayer:

(GKCloudPlayer *)player;

Page 78: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Game Session Examples

Page 79: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleTurn-Based Game

Player3

Player2

Player4

Player1

Game Data

Page 80: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleTurn-Based Game

Player3

Player2

Player4

Player1

Game Data

Page 81: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleTurn-Based Game

Player3

Player2

Player4

Player1

Game Data

1

Page 82: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleTurn-Based Game

Player3

Player2

Player4

Player1

Game Data

Page 83: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleTurn-Based Game

Player3

Player2

Player4

Player1

Game Data

1

Page 84: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 85: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 86: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 87: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 88: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 89: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 90: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

ExampleReal-Time Game

Player3

Player2

Player4

Player1

Game Data

Page 91: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: complex turnsGame Sessions

Players trading cards• Players want to trade with others during

their turn• Send a message with relevant data • Players can respond with their own offers• Resolve on the current players device, finish

turn, and save data

Player 2

Player 3

Player 1

Game Data

Player 4

Page 92: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: complex turnsGame Sessions

Players trading cards• Players want to trade with others during

their turn• Send a message with relevant data • Players can respond with their own offers• Resolve on the current players device, finish

turn, and save data

Player 2

Player 3

Player 1

Game Data

Player 4

1

1 1

Page 93: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: complex turnsGame Sessions

Players trading cards• Players want to trade with others during

their turn• Send a message with relevant data • Players can respond with their own offers• Resolve on the current players device, finish

turn, and save data

Player 2

Player 3

Player 1

Game Data

Player 4

1 1

1

Page 94: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: complex turnsGame Sessions

Players trading cards• Players want to trade with others during

their turn• Send a message with relevant data • Players can respond with their own offers• Resolve on the current players device, finish

turn, and save data

Player 2

Player 3

Player 1

Game Data

Player 4

Page 95: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 96: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 97: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 98: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 99: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 100: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 101: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 102: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 103: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 104: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 105: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 106: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 107: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Invite many people to the sessionStart a streamAnother player joins, enter a fightAs soon as one player is eliminated, the next is allowed to connect, and fightNo wait between fights, connections happen automatically

Use case: mid-stream join multiplayerGame Sessions

Player 3

Player 1

Player 4

Player 2

Game Data

Page 108: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player1

Page 109: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player1

Page 110: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player1

Page 111: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player 2

Player1

Page 112: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player 2

Player1

Page 113: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player1

Page 114: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Use case: assisted single playerGame Sessions

Playing a single player platformerCan’t get past a levelShare game with another player, allow them to help you advance Game Data

Player1

Page 115: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

SummaryGame Sessions

Play with anyoneMore flexible game structureSimple multiplayer connectionsNew possible game styles

Page 116: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

What’s New in Game Center

Message based multiplayer invitesRemoved Game Center appPersistent Game SessionsApple Watch support

Page 117: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

More Information

https://developer.apple.com/wwdc16/611

Page 118: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Related Sessions

Game Technologies for Apple Watch Mission Friday 3:00PM

Go Live with ReplayKit Mission Tuesday 10:00AM

What’s New in SpriteKit Presidio Thursday 5:00PM

What’s New in GameplayKit Pacific Heights Thursday 9:00AM

Controlling Game Input for Apple TV Mission Wednesday 5:00PM

Page 119: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled

Labs

Game Center Lab Graphic, Games, and Media Lab A Friday 12:00PM

watchOS Graphics and Games Graphic, Games, and Media Lab B Friday 4:00PM

Page 120: What’s New in Game Center - Apple Developer · • Stored in users iCloud • Follows Cloud Kit conventions Messages and Badges • Game Center Notifications • Badging controlled