-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameKit.framework.h
More file actions
2877 lines (2156 loc) · 150 KB
/
GameKit.framework.h
File metadata and controls
2877 lines (2156 loc) · 150 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== GameKit.framework/Headers/GKChallenge.h
//
// GKChallenge.h
// Game Center
//
// Copyright 2012-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameKit/GKScore.h>
#import <GameKit/GKAchievement.h>
NS_ASSUME_NONNULL_BEGIN
#if TARGET_OS_IPHONE
@class UIViewController;
typedef void (^GKChallengeComposeCompletionBlock)(UIViewController *composeController, BOOL didIssueChallenge, NSArray<NSString *> * __nullable sentPlayerIDs);
#else
@class NSViewController;
typedef void (^GKChallengeComposeCompletionBlock)(NSViewController *composeController, BOOL didIssueChallenge, NSArray<NSString *> * __nullable sentPlayerIDs);
#endif
@class GKPlayer;
typedef NS_ENUM(NSInteger, GKChallengeState) {
GKChallengeStateInvalid = 0,
GKChallengeStatePending = 1, // The challenge has been issued, but neither completed nor declined
GKChallengeStateCompleted = 2, // The challenge has been completed by the receiving player
GKChallengeStateDeclined = 3, // The challenge has been declined by the receiving player
};
NS_CLASS_AVAILABLE(10_8, 6_0) __WATCHOS_PROHIBITED
@interface GKChallenge : NSObject <NSCoding, NSSecureCoding>
// Query challenges for the current game issued to the local player -- equivalent GKChallenge objects are not guaranteed to be pointer equivalent across calls, but equal GKChallenge objects will have equal hashes
+ (void)loadReceivedChallengesWithCompletionHandler:(void(^ __nullable)(NSArray<GKChallenge *> * __nullable challenges, NSError * __nullable error))completionHandler;
// Any GKChallenge object to be declined must be in a state of GKChallengeStatePending in order to be successfully cancelled
- (void)decline;
@property (nonatomic, readonly, nullable, copy) NSString *issuingPlayerID NS_DEPRECATED(10_8, 10_10, 6_0, 8_0, "Use issuingPlayer instead") ;
@property (nonatomic, readonly, nullable, copy) NSString *receivingPlayerID NS_DEPRECATED(10_8, 10_10, 6_0, 8_0, "Use receivingPlayer instead") ;
@property (nonatomic, readonly, nullable, copy) GKPlayer *issuingPlayer NS_AVAILABLE(10_10, 8_0); // The GKPlayer who issued the challenge
@property (nonatomic, readonly, nullable, copy) GKPlayer *receivingPlayer NS_AVAILABLE(10_10, 8_0); // The GKPlayer who has received the challenge
@property (nonatomic, readonly, assign) GKChallengeState state; // Current state of the challenge
@property (nonatomic, readonly, retain) NSDate *issueDate; // Date the challenge was issued
@property (nonatomic, readonly, nullable, retain) NSDate *completionDate; // Date the challenge was completed or aborted
@property (nonatomic, readonly, nullable, copy) NSString *message; // The message sent to receivers of this challenge
@end
NS_CLASS_AVAILABLE(10_8, 6_0) __WATCHOS_PROHIBITED
@interface GKScoreChallenge : GKChallenge
@property (nonatomic, readonly, nullable, retain) GKScore *score; // The score to meet to satisfy this challenge
@end
NS_CLASS_AVAILABLE(10_8, 6_0) __WATCHOS_PROHIBITED
@interface GKAchievementChallenge : GKChallenge
@property (nonatomic, readonly, nullable, retain) GKAchievement *achievement; // The achievement to achieve to satisfy this challenge
@end
// Use the following category methods to issue GKScoreChallenges and GKAchievementChallenges to an array of playerIDs. Players may not issue challenges to themselves nor to non-friends. Please see the GameKit reference documentation for further details on these methods.
#if !TARGET_OS_WATCH
@interface GKScore (GKChallenge)
// Return a challenge compose view controller with pre-selected GKPlayers and a preformatted, player-editable message. Once this view controller is displayed, and the player sends or cancels sending the challenge, the completion handler will be called. This block contains the view controller, the reason why the handler was called, as well as which (if any) GKPlayers the challenge was sent to. Present modally from the top view controller. The completion handler should dismiss the view controller.
#if TARGET_OS_IPHONE
- (UIViewController *)challengeComposeControllerWithMessage:(nullable NSString *)message players:(nullable NSArray<GKPlayer *> *)players completionHandler:(nullable GKChallengeComposeCompletionBlock)completionHandler NS_AVAILABLE_IOS(8_0);
#else
- (NSViewController *)challengeComposeControllerWithMessage:(nullable NSString *)message players:(nullable NSArray<GKPlayer *> *)players completionHandler:(nullable GKChallengeComposeCompletionBlock)completionHandler NS_AVAILABLE_MAC(10_10);
#endif
// As of iOS 7.0, this will present a challenge dialogue to the player before the challenge is actually sent. Please use challengeComposeControllerWithPlayers:message:completion: instead.
- (void)issueChallengeToPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message NS_DEPRECATED(10_8, 10_10, 6_0, 7_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:completionHandler: and present the view controller instead") ;
// Use this alternative to reportScores:withCompletionHandler: to allow only certain specific challenges to be completed. Pass nil to avoid completing any challenges.
+ (void)reportScores:(NSArray<GKScore *> *)scores withEligibleChallenges:(NSArray<GKChallenge *> *)challenges withCompletionHandler:(void(^ __nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0);
@end
@interface GKAchievement (GKChallenge)
// If an achievement has already been earned by the receiving player, and that achievement is not marked as replayable in iTunes connect, then the challenge will not be issued to the player. If an achievement is hidden, then it will not be issued.
// Return a challenge compose view controller with pre-selected GKPlayers and a preformatted, player-editable message. Once this view controller is displayed, and the player sends or cancels sending the challenge, the completion handler will be called. This block contains the view controller, the reason why the handler was called, as well as which (if any) GKPlayers the challenge was sent to. Present modally from the top view controller. The completion handler should dismiss the view controller.
#if TARGET_OS_IPHONE
- (UIViewController *)challengeComposeControllerWithMessage:(nullable NSString *)message players:(NSArray<GKPlayer *> *)players completionHandler:(__nullable GKChallengeComposeCompletionBlock)completionHandler NS_AVAILABLE_IOS(8_0);
#else
- (NSViewController *)challengeComposeControllerWithMessage:(nullable NSString *)message players:(NSArray<GKPlayer *> *)players completionHandler:(__nullable GKChallengeComposeCompletionBlock)completionHandler NS_AVAILABLE_MAC(10_10);
#endif
// As of iOS 7.0 and Mac OS X 10.10, this will present a challenge dialogue to the player before the challenge is actually sent. Please use challengeComposeControllerWithPlayers:message:completion: instead.
- (void)issueChallengeToPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message NS_DEPRECATED(10_8, 10_10, 6_0, 7_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:completionHandler: and present the view controller instead") ;
// Given a list of players, return a subset of that list containing only players that are eligible to receive a challenge for the achievement.
- (void)selectChallengeablePlayers:(NSArray<GKPlayer *> *)players withCompletionHandler:(void(^ __nullable)(NSArray<GKPlayer *> * __nullable challengeablePlayers, NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 8_0);
// Use this alternative to reportAchievements:withCompletionHandler: to allow only certain specific challenges to be completed. Pass nil to avoid completing any challenges.
+ (void)reportAchievements:(NSArray<GKAchievement *> *)achievements withEligibleChallenges:(NSArray<GKChallenge *> *)challenges withCompletionHandler:(void(^ __nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0);
@end
@interface GKScore (GKChallengeDeprecated)
#if TARGET_OS_IPHONE
- (nullable UIViewController *)challengeComposeControllerWithPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message completionHandler:(__nullable GKChallengeComposeCompletionBlock)completionHandler NS_DEPRECATED_IOS(7_0, 8_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:") ;
#endif
// As of iOS 7.0, this will present a challenge dialogue to the player before the challenge is actually sent. Please use challengeComposeControllerWithPlayers:message:completion: instead.
- (void)issueChallengeToPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message NS_DEPRECATED(10_8, 10_10, 6_0, 7_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:completionHandler: and present the view controller instead") ;
@end
@interface GKAchievement (GKChallengeDeprecated)
- (void)selectChallengeablePlayerIDs:(nullable NSArray<NSString *> *)playerIDs withCompletionHandler:(void(^__nullable)(NSArray<NSString *> * __nullable challengeablePlayerIDs, NSError * __nullable error))completionHandler NS_DEPRECATED(10_8, 10_10, 6_0, 8_0, "pass GKPlayers to selectChallengeablePlayers:") ;
// As of iOS 7.0 and Mac OS X 10.10, this will present a challenge dialogue to the player before the challenge is actually sent. Please use challengeComposeControllerWithPlayers:message:completion: instead.
- (void)issueChallengeToPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message NS_DEPRECATED(10_8, 10_10, 6_0, 7_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:completionHandler: and present the view controller instead") ;
#if TARGET_OS_IPHONE
- (nullable UIViewController *)challengeComposeControllerWithPlayers:(nullable NSArray<NSString *> *)playerIDs message:(nullable NSString *)message completionHandler:(nullable GKChallengeComposeCompletionBlock)completionHandler NS_DEPRECATED_IOS(7_0, 8_0, "pass GKPlayers to challengeComposeControllerWithMessage:players:") ;
#endif
@end
#endif
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GKBasePlayer.h
//
// GKBasePlayer.h
// Game Center
//
// Copyright 2016-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameKit/GKDefines.h>
NS_CLASS_AVAILABLE(10_12, 10_0) __WATCHOS_AVAILABLE(3_0)
@interface GKBasePlayer : NSObject
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSString *playerID;
// This player's full name as displayed in the Game Center in-game UI. Use this when you need to display the player's name. The display name may be very long, so be sure to use appropriate string truncation API when drawing.
@property(readonly, nullable, NS_NONATOMIC_IOSONLY) NSString *displayName;
@end
// ========== GameKit.framework/Headers/GKGameSessionError.h
//
// GKGameSessionError.h
// Game Center
//
// Copyright 2016-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
extern NSString * __nonnull GKGameSessionErrorDomain API_DEPRECATED("GKGameSession is deprecated, use real-time and turn-based matchmaking APIs instead.", ios(10.0, 12.0), tvos(10.0, 12.0), macosx(10.12, 10.14)) API_UNAVAILABLE(watchos);
typedef NS_ENUM(NSInteger, GKGameSessionErrorCode) {
GKGameSessionErrorUnknown = 1,
GKGameSessionErrorNotAuthenticated = 2,
GKGameSessionErrorSessionConflict = 3,
GKGameSessionErrorSessionNotShared = 4,
GKGameSessionErrorConnectionCancelledByUser = 5,
GKGameSessionErrorConnectionFailed = 6,
GKGameSessionErrorSessionHasMaxConnectedPlayers = 7,
GKGameSessionErrorSendDataNotConnected = 8,
GKGameSessionErrorSendDataNoRecipients = 9,
GKGameSessionErrorSendDataNotReachable = 10,
GKGameSessionErrorSendRateLimitReached = 11,
GKGameSessionErrorBadContainer = 12,
GKGameSessionErrorCloudQuotaExceeded = 13,
GKGameSessionErrorNetworkFailure = 14,
GKGameSessionErrorCloudDriveDisabled = 15,
GKGameSessionErrorInvalidSession = 16,
} API_DEPRECATED("GKGameSession is deprecated, use real-time and turn-based matchmaking APIs instead.", ios(10.0, 12.0), tvos(10.0, 12.0), macosx(10.12, 10.14)) API_UNAVAILABLE(watchos);
// ========== GameKit.framework/Headers/GKAchievementViewController.h
//
// GKAchievementViewController.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
#endif
#import <GameKit/GKGameCenterViewController.h>
@protocol GKAchievementViewControllerDelegate;
// View controller that provides the standard user interface for achievements. Present modally from the top view controller.
NS_CLASS_DEPRECATED(10_8, 10_10, 4_1, 7_0, "Use GKGameCenterViewController instead")
@interface GKAchievementViewController : GKGameCenterViewController
#if !TARGET_OS_IPHONE
{
id<GKAchievementViewControllerDelegate> _achievementDelegate;
}
#endif
@end
@interface GKAchievementViewController ()
@property (assign, NS_NONATOMIC_IOSONLY) id<GKAchievementViewControllerDelegate> achievementDelegate;
@end
// Optional delegate
NS_DEPRECATED(10_8, 10_10, 4_1, 7_0, "Use GKGameCenterViewController instead")
@protocol GKAchievementViewControllerDelegate <NSObject>
@required
// The achievement view has finished
- (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController;
@end
// ========== GameKit.framework/Headers/GKGameCenterViewController.h
//
// GKGameCenterViewController.h
// Game Center
//
// Copyright 2012-2019 Apple Inc. All rights reserved.
//
#import <GameKit/GKLeaderboard.h>
@protocol GKGameCenterControllerDelegate;
typedef NS_ENUM(NSInteger, GKGameCenterViewControllerState) {
GKGameCenterViewControllerStateDefault = -1,
GKGameCenterViewControllerStateLeaderboards,
GKGameCenterViewControllerStateAchievements,
GKGameCenterViewControllerStateChallenges,
};
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <GameCenterUICore/GKDialogController.h>
#endif
NS_ASSUME_NONNULL_BEGIN
// View controller that provides the standard user interface for leaderboards, achievements, and challenges. Present modally from the top view controller.
#if TARGET_OS_IPHONE
NS_CLASS_AVAILABLE(10_9, 6_0)
@interface GKGameCenterViewController : UINavigationController
@end
#else
NS_CLASS_AVAILABLE(10_9, 6_0)
@interface GKGameCenterViewController : NSViewController <GKViewController> {
id _internal1, __weak _internal2, _internal3;
GKGameCenterViewControllerState _viewState;
NSString *_leaderboardIdentifier;
NSString *_leaderboardCategory;
GKLeaderboardTimeScope _leaderboardTimeScope;
BOOL _internalFlag;
}
@end
#endif
@interface GKGameCenterViewController ()
@property (weak, nullable, NS_NONATOMIC_IOSONLY) id<GKGameCenterControllerDelegate> gameCenterDelegate;
@property (assign, NS_NONATOMIC_IOSONLY) GKGameCenterViewControllerState viewState ;
@end
@interface GKGameCenterViewController (Leaderboards)
@property (nonatomic, assign) GKLeaderboardTimeScope leaderboardTimeScope NS_AVAILABLE(10_8, 4_1) ;
@property (nonatomic, nullable, strong) NSString *leaderboardIdentifier NS_AVAILABLE(10_10, 7_0) ;
@property (nonatomic, nullable, strong) NSString *leaderboardCategory NS_DEPRECATED(10_8, 10_10, 4_1, 7_0, "GKGameCenterViewController's leaderboardCategory property is deprecated. Use leaderboardIdentifier instead.") ;
@end
@protocol GKGameCenterControllerDelegate <NSObject>
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController NS_AVAILABLE(10_9, 6_0);
@end
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GKGameSession.h
//
// GKGameSession.h
// Game Center
//
// Copyright 2016-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameKit/GKDefines.h>
@class GKCloudPlayer;
typedef NS_ENUM(NSInteger, GKConnectionState) {
GKConnectionStateNotConnected,
GKConnectionStateConnected
};
typedef NS_ENUM(NSInteger, GKTransportType) {
GKTransportTypeUnreliable,
GKTransportTypeReliable
};
NS_ASSUME_NONNULL_BEGIN
API_DEPRECATED("For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController.", ios(10.0, 12.0), tvos(10.0, 12.0), macosx(10.12, 10.14)) API_UNAVAILABLE(watchos)
@interface GKGameSession : NSObject
#if !__OBJC2__
{
NSString *_identifier;
NSString *_title;
GKCloudPlayer *_owner;
NSArray<GKCloudPlayer *> *_players;
NSDate *_lastModifiedDate;
GKCloudPlayer *_lastModifiedPlayer;
NSString *_serverChangeTag;
NSInteger _maxNumberOfConnectedPlayers;
NSMutableDictionary<NSString*, NSArray<NSNumber*> *> *_playerStates;
}
#endif
@property (nonatomic, readonly) NSString *identifier;
@property (nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) GKCloudPlayer *owner;
@property (nonatomic, readonly) NSArray<GKCloudPlayer *> *players;
@property (nonatomic, readonly) NSDate *lastModifiedDate;
@property (nonatomic, readonly) GKCloudPlayer *lastModifiedPlayer;
@property (nonatomic, readonly) NSInteger maxNumberOfConnectedPlayers;
@property (nonatomic, readonly) NSArray<GKCloudPlayer *> *badgedPlayers;
// Create a new session with the given title and maximum number of connected players. (You may pass 0 to use the system limit of 16 players.)
+ (void)createSessionInContainer:(NSString * __nullable)containerName withTitle:(NSString *)title maxConnectedPlayers:(NSInteger)maxPlayers completionHandler:(void(^)(GKGameSession * __nullable session, NSError * __nullable error))completionHandler;
// Load all sessions involving the current user.
+ (void)loadSessionsInContainer:(NSString * __nullable)containerName completionHandler:(void(^)(NSArray<GKGameSession *> * __nullable sessions, NSError * __nullable error))completionHandler;
// Load a specific session.
+ (void)loadSessionWithIdentifier:(NSString *)identifier completionHandler:(void(^)(GKGameSession * __nullable session, NSError * __nullable error))completionHandler;
// Remove a session. If called by the owner this deletes the session from the server.
+ (void)removeSessionWithIdentifier:(NSString *)identifier completionHandler:(void(^)(NSError * __nullable error))completionHandler;
// Get the URL needed to share this session.
- (void)getShareURLWithCompletionHandler:(void(^)(NSURL * __nullable url, NSError * __nullable error))completionHandler;
// Load associated persistent data.
- (void)loadDataWithCompletionHandler:(void(^)(NSData * __nullable data, NSError * __nullable error))completionHandler;
// Save new/updated persistent data. Data size is limited to 512K. The session's lastModifiedDate and lastModifiedPlayer will be updated upon completion.
// If a version conflict is detected the handler will include the version currently on the server and an error. In this case the data has not been saved. To resolve the conflict a client would call this method again, presumably after merging data or giving the user a choice on how to resolve the conflict. (Note that when calling again it is possible to get a new conflict, if another device has since written a new version.)
- (void)saveData:(NSData *)data completionHandler:(void(^)(NSData * __nullable conflictingData, NSError * __nullable error))completionHandler;
// Set your connection state. May fail if you attempt to connect but the connected player limit has already been reached or there are network problems. The session's lastModifiedDate and lastModifiedPlayer will be updated upon completion.
- (void)setConnectionState:(GKConnectionState)state completionHandler:(void(^)(NSError * __nullable error))completionHandler;
// Get the players with the given connection state.
- (NSArray<GKCloudPlayer *> *)playersWithConnectionState:(GKConnectionState)state;
// Send data to all connected players.
- (void)sendData:(NSData *)data withTransportType:(GKTransportType)transport completionHandler:(void(^)(NSError * __nullable error))completionHandler;
// Send a message to any players in the session. This uses an unreliable push mechanism. Message/data delivery is not guaranteed and may take some time to arrive. Receiving players may optionally have their application badged for this session.
- (void)sendMessageWithLocalizedFormatKey:(NSString *)key arguments:(NSArray<NSString *> *)arguments data:(NSData * __nullable)data toPlayers:(NSArray<GKCloudPlayer *> *)players badgePlayers:(BOOL)badgePlayers completionHandler:(void(^)(NSError * __nullable error))completionHandler;
// Clear application badge state for players for this session.
- (void)clearBadgeForPlayers:(NSArray<GKCloudPlayer *> *)players completionHandler:(void(^)(NSError * __nullable error))completionHandler;
@end
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GKPlayer.h
//
// GKPlayer.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameKit/GKBasePlayer.h>
#import <GameKit/GKDefines.h>
#import <GameKit/GKError.h>
@class GKPlayerInternal;
@class GKGame;
@class GKLocalPlayer;
@class UIImage;
NS_CLASS_AVAILABLE(10_8, 4_1) __WATCHOS_AVAILABLE(3_0)
@interface GKPlayer : GKBasePlayer
// Load the Game Center players for the playerIDs provided. Error will be nil on success.
// Possible reasons for error:
// 1. Unauthenticated local player
// 2. Communications failure
// 3. Invalid player identifier
+ (void)loadPlayersForIdentifiers:(nonnull NSArray<NSString *> *)identifiers withCompletionHandler:(void(^__nullable)(NSArray<GKPlayer *> * __nullable players, NSError * __nullable error))completionHandler;
// This is the local player's unique and persistent ID that is scoped to this application. For non-local players, this ID is unique for this instantiation of this app.
@property(NS_NONATOMIC_IOSONLY, readonly, nonnull, retain) NSString *gamePlayerID API_AVAILABLE(ios(12.4), macos(10.14.6), tvos(12.4)) API_UNAVAILABLE(watchos);
// This is the local player's unique and persistent ID that is scoped to the Apple Store Connect Team identifier of this application. For non-local players, this ID is unique for this instantiation of this app.
@property(NS_NONATOMIC_IOSONLY, readonly, nonnull, retain) NSString *teamPlayerID API_AVAILABLE(ios(12.4), macos(10.14.6), tvos(12.4)) API_UNAVAILABLE(watchos);
// This is player's alias to be displayed. The display name may be very long, so be sure to use appropriate string truncation API when drawing.
@property(readonly, nonnull, NS_NONATOMIC_IOSONLY) NSString *displayName NS_AVAILABLE(10_8, 6_0) __WATCHOS_AVAILABLE(3_0);
// The alias property contains the player's nickname. When you need to display the name to the user, consider using displayName instead. The nickname is unique but not invariant: the player may change their nickname. The nickname may be very long, so be sure to use appropriate string truncation API when drawing.
@property(readonly, copy, nonnull, NS_NONATOMIC_IOSONLY) NSString *alias;
+ (nonnull instancetype)anonymousGuestPlayerWithIdentifier:(nonnull NSString *)guestIdentifier NS_AVAILABLE(10_11, 9_0) __WATCHOS_PROHIBITED;
@property(readonly, nullable, NS_NONATOMIC_IOSONLY) NSString *guestIdentifier NS_AVAILABLE(10_11, 9_0) __WATCHOS_PROHIBITED;
@end
#import <GameKit/GKPlayer.h>
@interface GKPlayer (UI)
// Available photo sizes. Actual pixel dimensions will vary on different devices.
typedef NS_ENUM(NSInteger, GKPhotoSize) {
GKPhotoSizeSmall = 0,
GKPhotoSizeNormal,
};
// Asynchronously load the player's photo. Error will be nil on success.
// Possible reasons for error:
// 1. Communications failure
#if TARGET_OS_IPHONE
- (void)loadPhotoForSize:(GKPhotoSize)size withCompletionHandler:(void(^__nullable)(UIImage * __nullable photo, NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 5_0);
#else
- (void)loadPhotoForSize:(GKPhotoSize)size withCompletionHandler:(void(^__nullable)(NSImage * __nullable photo, NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 5_0);
#endif
@end
// Notification will be posted whenever the player details changes. The object of the notification will be the player.
GK_EXTERN_WEAK NSNotificationName __nonnull GKPlayerDidChangeNotificationName;
@interface GKPlayer (Deprecated)
@property(readonly, NS_NONATOMIC_IOSONLY) BOOL isFriend NS_DEPRECATED(10_8, 10_10, 4_1, 8_0, "use -[GKLocalPlayer loadFriendPlayers...]") ; // True if this player is a friend of the local player
@property(readonly, nonnull, retain, NS_NONATOMIC_IOSONLY) NSString *playerID GK_API_DEPRECATED( "use the teamPlayerID property to identify a player",ios(4.1,13.0),tvos(9.0,13.0),macosx(10.8,10.15));
@end
// ========== GameKit.framework/Headers/GKDefines.h
//
// GKDefines.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#ifndef GK_EXTERN
#ifdef __cplusplus
#define GK_EXTERN extern "C" __attribute__((visibility ("default")))
#else
#define GK_EXTERN extern __attribute__((visibility ("default")))
#endif
#endif
#ifndef GK_EXTERN_WEAK
#define GK_EXTERN_WEAK GK_EXTERN __attribute__((weak_import))
#endif
#if !defined(__GK_HAS_COMPILER_ATTRIBUTE)
# if defined(__has_attribute)
# define __GK_HAS_COMPILER_ATTRIBUTE(attribute) __has_attribute(attribute)
# elif defined(__GNUC__) && __GNUC__ >= 4
# define __GK_HAS_COMPILER_ATTRIBUTE(attribute) (1)
# else
# define __GK_HAS_COMPILER_ATTRIBUTE(attribute) (0)
# endif
#endif
#if !defined(GK_API_DEPRECATED)
# if __GK_HAS_COMPILER_ATTRIBUTE(deprecated) && !defined(GK_BUILDING_GK)
# define GK_API_DEPRECATED(...) API_DEPRECATED(__VA_ARGS__)
# else
# define GK_API_DEPRECATED(...)
# endif
#endif
// ========== GameKit.framework/Headers/GKCloudPlayer.h
//
// GKCloudPlayer.h
// Game Center
//
// Copyright 2016-2019 Apple Inc. All rights reserved.
//
#import <GameKit/GKBasePlayer.h>
NS_ASSUME_NONNULL_BEGIN
API_DEPRECATED("GKGameSession is deprecated. Use GKPlayer for both real-time and turn-based matchmaking APIs.", ios(10.0, 12.0), tvos(10.0, 12.0), macosx(10.12, 10.14)) API_UNAVAILABLE(watchos)
@interface GKCloudPlayer : GKBasePlayer
#if !__OBJC2__
{
NSString *_identifier;
NSString *_name;
}
#endif
// Retrieve a player instance representing the active iCloud account for a given iCloud container. Returns nil and an error if the user is not signed in to iCloud or the container is invalid.
+ (void)getCurrentSignedInPlayerForContainer:(NSString * __nullable)containerName completionHandler:(void(^)(GKCloudPlayer *__nullable player, NSError * __nullable error))handler;
@end
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GameKit.h
//
// GameKit.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#import <TargetConditionals.h>
#import <simd/simd.h>
#import <UIKit/UIKit.h>
#if !TARGET_OS_SIMULATOR
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#endif
#import <SpriteKit/SpriteKit.h>
#import <SceneKit/SceneKit.h>
#import <GameplayKit/GameplayKit.h>
#import <GameController/GameController.h>
#import <ModelIO/ModelIO.h>
#import <ReplayKit/ReplayKit.h>
#import <GameKit/GKDefines.h>
#import <GameKit/GKAchievement.h>
#import <GameKit/GKAchievementDescription.h>
#import <GameKit/GKAchievementViewController.h>
#import <GameKit/GKBasePlayer.h>
#import <GameKit/GKChallenge.h>
#import <GameKit/GKChallengeEventHandler.h>
#import <GameKit/GKCloudPlayer.h>
#import <GameKit/GKError.h>
#import <GameKit/GKEventListener.h>
#import <GameKit/GKFriendRequestComposeViewController.h>
#import <GameKit/GKGameCenterViewController.h>
#import <GameKit/GKGameSession.h>
#import <GameKit/GKGameSessionError.h>
#import <GameKit/GKGameSessionEventListener.h>
#import <GameKit/GKGameSessionSharingViewController.h>
#import <GameKit/GKLeaderboard.h>
#import <GameKit/GKLeaderboardSet.h>
#import <GameKit/GKLeaderboardViewController.h>
#import <GameKit/GKLocalPlayer.h>
#import <GameKit/GKMatch.h>
#import <GameKit/GKMatchmaker.h>
#import <GameKit/GKMatchmakerViewController.h>
#import <GameKit/GKNotificationBanner.h>
#import <GameKit/GKPeerPickerController.h>
#import <GameKit/GKPlayer.h>
#import <GameKit/GKPublicConstants.h>
#import <GameKit/GKPublicProtocols.h>
#import <GameKit/GKRemoteUIController.h>
#import <GameKit/GKSavedGame.h>
#import <GameKit/GKSavedGameListener.h>
#import <GameKit/GKScore.h>
#import <GameKit/GKSession.h>
#import <GameKit/GKSessionError.h>
#import <GameKit/GKTurnBasedMatch.h>
#import <GameKit/GKTurnBasedMatchmakerViewController.h>
#import <GameKit/GKVoiceChat.h>
#import <GameKit/GKVoiceChatService.h>
// ========== GameKit.framework/Headers/GKMatch.h
//
// GKMatch.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GKVoiceChat;
@class GKPlayer;
@class GKLocalPlayer;
@class GKThreadsafeDictionary;
@protocol GKMatchDelegate;
typedef NS_ENUM(NSInteger, GKMatchSendDataMode) {
GKMatchSendDataReliable, // a.s.a.p. but requires fragmentation and reassembly for large messages, may stall if network congestion occurs
GKMatchSendDataUnreliable // Preferred method. Best effort and immediate, but no guarantees of delivery or order; will not stall.
};
typedef NS_ENUM(NSInteger, GKPlayerConnectionState) {
GKPlayerStateUnknown, // initial player state
GKPlayerStateConnected, // connected to the match
GKPlayerStateDisconnected // disconnected from the match
};
NS_ASSUME_NONNULL_BEGIN
// GKMatch represents an active networking sessions between players. It handles network communications and can report player connection status. All matches are created by a GKMatchmaker.
NS_CLASS_AVAILABLE(10_8, 4_1) __WATCHOS_PROHIBITED
@interface GKMatch : NSObject
@property(nonatomic, readonly) NSArray<GKPlayer *> *players NS_AVAILABLE(10_10, 8_0); // GKPlayers in the match
@property(nonatomic, nullable, assign) id<GKMatchDelegate> delegate;
@property(nonatomic, readonly) NSUInteger expectedPlayerCount;
// Asynchronously send data to one or more GKPlayers. Returns YES if delivery started, NO if unable to start sending and error will be set.
- (BOOL)sendData:(NSData *)data toPlayers:(NSArray<GKPlayer *> *)players dataMode:(GKMatchSendDataMode)mode error:(NSError * __nullable * __nullable)error NS_AVAILABLE(10_10, 8_0);
// Asynchronously broadcasts data to all players. Returns YES if delivery started, NO if unable to start sending and error will be set.
- (BOOL)sendDataToAllPlayers:(NSData *)data withDataMode:(GKMatchSendDataMode)mode error:(NSError * __nullable * __nullable)error;
// Disconnect the match. This will show all other players in the match that the local player has disconnected. This should be called before releasing the match instance.
- (void)disconnect;
// Join a named voice chat channel
// Will return nil if parental controls are turned on
- (nullable GKVoiceChat *)voiceChatWithName:(NSString *)name;
// Choose the best host from among the connected players using gathered estimates for bandwidth and packet loss. This is intended for applications that wish to implement a client-server model on top of the match. The returned player ID will be nil if the best host cannot currently be determined (e.g. players are still connecting).
- (void)chooseBestHostingPlayerWithCompletionHandler:(void(^)(GKPlayer * __nullable player))completionHandler NS_AVAILABLE(10_10, 8_0);
// Auto-matching to recreate a previous peer-to-peer match that became disconnected. A new match with the same set of players will be returned by the completion handler. All players should perform this when the match has ended for auto-matching to succeed. Error will be nil on success.
// Possible reasons for error:
// 1. Communications failure
// 2. Timeout
- (void)rematchWithCompletionHandler:(void(^__nullable)(GKMatch * __nullable match, NSError * __nullable error))completionHandler NS_AVAILABLE(10_9, 6_0);
@end
__WATCHOS_PROHIBITED
@protocol GKMatchDelegate <NSObject>
@optional
// The match received data sent from the player.
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromRemotePlayer:(GKPlayer *)player NS_AVAILABLE(10_10, 8_0);
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data forRecipient:(GKPlayer *)recipient fromRemotePlayer:(GKPlayer *)player NS_AVAILABLE(10_11, 9_0);
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromPlayer:(NSString *)playerID NS_DEPRECATED(10_8, 10_10, 4_1, 8_0, "use match:didReceiveData:fromRemotePlayer:") ;
// The player state changed (eg. connected or disconnected)
- (void)match:(GKMatch *)match player:(GKPlayer *)player didChangeConnectionState:(GKPlayerConnectionState)state NS_AVAILABLE(10_8, 4_1);
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state NS_DEPRECATED(10_8, 10_8, 4_1, 8_0, "use match:player:didChangeConnectionState:") ;
// The match was unable to be established with any players due to an error.
- (void)match:(GKMatch *)match didFailWithError:(nullable NSError *)error NS_AVAILABLE(10_8, 4_1);
// This method is called when the match is interrupted; if it returns YES, a new invite will be sent to attempt reconnection. This is supported only for 1v1 games
- (BOOL)match:(GKMatch *)match shouldReinviteDisconnectedPlayer:(GKPlayer *)player NS_AVAILABLE(10_10, 8_0);
- (BOOL)match:(GKMatch *)match shouldReinvitePlayer:(NSString *)playerID NS_DEPRECATED(10_8, 10_10, 5_0, 8_0, "use shouldReinviteDisconnectedPlayer:") ;
@end
@interface GKMatch (Deprecated)
- (void)chooseBestHostPlayerWithCompletionHandler:(void(^)(NSString * __nullable playerID))completionHandler NS_DEPRECATED(10_9, 10_10, 6_0, 8_0, "use chooseBestHostingPlayerWithCompletionHandler:") ;
- (BOOL)sendData:(NSData *)data toPlayers:(NSArray<NSString *> *)playerIDs withDataMode:(GKMatchSendDataMode)mode error:(NSError **)error NS_DEPRECATED(10_8, 10_10, 4_1, 8_0, "use sendData:toPlayers:dataMode:error:") ;
@property(nonatomic, readonly) NSArray<NSString *> *playerIDs NS_DEPRECATED(10_8, 10_10, 4_1, 8_0, "use players") ; // NSStrings of player identifiers in the match
@end
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GKTurnBasedMatch.h
//
// GKTurnBasedMatch.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//
#import <GameKit/GKPlayer.h>
@class GKMatchRequest, GKTurnBasedMatch, GKTurnBasedExchange, GKTurnBasedExchangeReply, GKScore, GKAchievement;
// Constants that describe the state of the overall match
typedef NS_ENUM(NSInteger, GKTurnBasedMatchStatus) {
GKTurnBasedMatchStatusUnknown = 0,
GKTurnBasedMatchStatusOpen = 1,
GKTurnBasedMatchStatusEnded = 2,
GKTurnBasedMatchStatusMatching = 3
};
// Constants that describe the state of individual participants in the match
typedef NS_ENUM(NSInteger, GKTurnBasedParticipantStatus) {
// Statuses that are set by GameKit
GKTurnBasedParticipantStatusUnknown = 0,
GKTurnBasedParticipantStatusInvited = 1, // a participant has been invited but not yet responded
GKTurnBasedParticipantStatusDeclined = 2, // a participant that has declined an invite to this match
GKTurnBasedParticipantStatusMatching = 3, // a participant that is waiting to be matched
GKTurnBasedParticipantStatusActive = 4, // a participant that is active in this match
GKTurnBasedParticipantStatusDone = 5, // a participant is done with this session
};
// Constants that describe the game result for a given participant who has reached the done state. The developer is free to use these constants or add additional ones
typedef NS_ENUM(NSInteger, GKTurnBasedMatchOutcome) {
GKTurnBasedMatchOutcomeNone = 0, // Participants who are not done with a match have this state
GKTurnBasedMatchOutcomeQuit = 1, // Participant quit
GKTurnBasedMatchOutcomeWon = 2, // Participant won
GKTurnBasedMatchOutcomeLost = 3, // Participant lost
GKTurnBasedMatchOutcomeTied = 4, // Participant tied
GKTurnBasedMatchOutcomeTimeExpired = 5, // Game ended due to time running out
GKTurnBasedMatchOutcomeFirst = 6,
GKTurnBasedMatchOutcomeSecond = 7,
GKTurnBasedMatchOutcomeThird = 8,
GKTurnBasedMatchOutcomeFourth = 9,
GKTurnBasedMatchOutcomeCustomRange = 0x00FF0000 // game result range available for custom app use
};
// GKTurnBasedMatch represents an ongoing turn-based game among the matched group of participants
// Existing matches can be shown and new matches created using GKTurnBasedMatchmakerViewController
// A list of existing matches can be retrieved using +loadMatchesWithCompletionHandler:
//
// By default turn based events will badge your app. To opt out of this add GKGameCenterBadgingDisabled with a boolean value of YES to your info plist
NS_CLASS_AVAILABLE(10_8, 5_0) __WATCHOS_AVAILABLE(3_0)
@interface GKTurnBasedParticipant : NSObject
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) GKPlayer *player NS_AVAILABLE(10_10, 8_0) __WATCHOS_AVAILABLE(3_0);
@property(readonly, nullable, copy, NS_NONATOMIC_IOSONLY) NSDate *lastTurnDate;
@property(readonly, NS_NONATOMIC_IOSONLY) GKTurnBasedParticipantStatus status;
@property(assign, NS_NONATOMIC_IOSONLY) GKTurnBasedMatchOutcome matchOutcome;
@property(readonly, nullable, copy, NS_NONATOMIC_IOSONLY) NSDate *timeoutDate NS_AVAILABLE(10_8, 6_0) __WATCHOS_AVAILABLE(3_0);
// Deprecated
@property(readonly, nullable, copy, NS_NONATOMIC_IOSONLY) NSString *playerID NS_DEPRECATED(10_8, 10_10, 5_0, 8_0, "use player") ;
@end
NS_ASSUME_NONNULL_BEGIN
@protocol GKTurnBasedEventListener
@optional
// If Game Center initiates a match the developer should create a GKTurnBasedMatch from playersToInvite and present a GKTurnbasedMatchmakerViewController.
- (void)player:(GKPlayer *)player didRequestMatchWithOtherPlayers:(NSArray<GKPlayer *> *)playersToInvite NS_AVAILABLE(10_10, 8_0) API_UNAVAILABLE(watchos);
// called when it becomes this player's turn. It also gets called under the following conditions:
// the player's turn has a timeout and it is about to expire.
// the player accepts an invite from another player.
// when the game is running it will additionally recieve turn events for the following:
// turn was passed to another player
// another player saved the match data
// Because of this the app needs to be prepared to handle this even while the player is taking a turn in an existing match. The boolean indicates whether this event launched or brought to forground the app.
- (void)player:(GKPlayer *)player receivedTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// called when the match has ended.
- (void)player:(GKPlayer *)player matchEnded:(GKTurnBasedMatch *)match;
// this is called when a player receives an exchange request from another player.
- (void)player:(GKPlayer *)player receivedExchangeRequest:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// this is called when an exchange is canceled by the sender.
- (void)player:(GKPlayer *)player receivedExchangeCancellation:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// called when all players either respond or timeout responding to this request. This is sent to both the turn holder and the initiator of the exchange
- (void)player:(GKPlayer *)player receivedExchangeReplies:(NSArray<GKTurnBasedExchangeReply *> *)replies forCompletedExchange:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// Called when a player chooses to quit a match and that player has the current turn. The developer should call participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:matchData:completionHandler: on the match passing in appropriate values. They can also update matchOutcome for other players as appropriate.
- (void)player:(GKPlayer *)player wantsToQuitMatch:(GKTurnBasedMatch *)match NS_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3_0);
// Deprecated
- (void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray<NSString *> *)playerIDsToInvite NS_DEPRECATED_IOS(7_0, 8_0, "use didRequestMatchWithOtherPlayers") ;
@end
// Turn timeout constants
extern NSTimeInterval GKTurnTimeoutDefault NS_AVAILABLE(10_9, 6_0) __WATCHOS_AVAILABLE(3_0); // use a default timeout of one week
extern NSTimeInterval GKTurnTimeoutNone NS_AVAILABLE(10_9, 6_0) __WATCHOS_AVAILABLE(3_0);
NS_CLASS_AVAILABLE(10_8, 5_0) __WATCHOS_AVAILABLE(3_0)
@interface GKTurnBasedMatch : NSObject
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSString *matchID;
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSDate *creationDate;
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedParticipant *> *participants; // array of GKTurnBasedParticipant objects
@property(readonly, NS_NONATOMIC_IOSONLY) GKTurnBasedMatchStatus status;
// This indicates the participant who has the current turn. This is set by passing the next participant into endTurnWithNextParticipant:matchData:completionHandler:
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) GKTurnBasedParticipant *currentParticipant;
// Developer-defined data representing the current state of the game. This property is nil until loaded by loadMatchDataWithCompletionHandler:
// The developer can submit updated matchData by passing it into endTurnWithNextParticipant:matchData:completionHandler: or endMatchInTurnWithMatchData:completionHandler:
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSData *matchData;
// If the developer wishes to display a message in GKTurnBasedMatchmakerViewController at the end of a turn or end of the match. Only the current participant can set this.
// Sets a localizable mesage that will be localized on the receiver side if the game is installed and on the sender side as a fallback.
// The key and arguments offer a subset of formated strings as follows
// key is a string in a Localizable.strings file for the current localization (which is set by the user’s language preference). key string can be formatted with %@ and %n$@ specifiers to take the variables specified in loc-args
// arguments is an array of strings that will be substituted using the format string.
// Notes: The localized message will be evaluated locally from these keys and sent across as well so that devices that do not have the game installed will see the message in the sender's localization
// The developer can access resulting string using the message property
// This is a similar concept to the way we handle localization for Push Notifications. See the "Local and Push Notification Programming Guide" for more details.
- (void)setLocalizableMessageWithKey:(NSString*)key arguments:(nullable NSArray<NSString *> *)arguments NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// returns the localizable message in the current locale. Setting this is equivalent to calling [self setLocalizableMessageWithKey:message arguments:nil]
@property(readwrite, nullable, copy, NS_NONATOMIC_IOSONLY) NSString *message;
// Returns the maximum size for the match data.
@property(readonly, NS_NONATOMIC_IOSONLY) NSUInteger matchDataMaximumSize NS_AVAILABLE(10_8, 6_0) __WATCHOS_AVAILABLE(3_0);
// exchanges that are in progress on this match. Once an exchange has completed and has been resolved by merging it into the match data by the current turn holder then it will be removed from this list
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedExchange *> *exchanges NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// returns the exchanges that currently await a reply from the local player
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedExchange *> *activeExchanges NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// returns the exchanges that have been completed and need to be merged by the local participant. This will be nil unless the local participant is the current turn holder for this match
@property(readonly, nullable, retain, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedExchange *> *completedExchanges NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// maximum data allowed for exchange data
@property(readonly, NS_NONATOMIC_IOSONLY) NSUInteger exchangeDataMaximumSize NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// limit of the number of exchanges that this player can have initiated at a given time
@property(readonly, NS_NONATOMIC_IOSONLY) NSUInteger exchangeMaxInitiatedExchangesPerPlayer NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// Attempt to find a turn-based match for the specified request. Error will be nil on success.
// Possible reasons for error:
// 1. Communications failure
// 2. Unauthenticated player
+ (void)findMatchForRequest:(GKMatchRequest *)request withCompletionHandler:(void(^)(GKTurnBasedMatch * __nullable match, NSError * __nullable error))completionHandler;
// This method retrieves the list of GKTurnBasedMatches that the current player is or has participated in. The callback’s array contains GKTurnBasedMatches
+ (void)loadMatchesWithCompletionHandler:(void(^__nullable)(NSArray<GKTurnBasedMatch *> * __nullable matches, NSError * __nullable error))completionHandler;
// load a match based on a previously known match ID
+ (void)loadMatchWithID:(NSString *)matchID withCompletionHandler:(void(^__nullable)(GKTurnBasedMatch * __nullable match, NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 5_0) __WATCHOS_AVAILABLE(3_0);
// Recreate a previously existing turn based match that ended. A new match with the same set of players will be returned by the completion handler. If multiple players do this then multiple new matches will be created. Error will be nil on success.
// Possible reasons for error:
// 1. Communications failure
// 2. Unauthenticated player
- (void)rematchWithCompletionHandler:(void(^__nullable)(GKTurnBasedMatch * __nullable match, NSError * __nullable error))completionHandler NS_AVAILABLE(10_9, 6_0) __WATCHOS_AVAILABLE(3_0);
// If the local participant has status invited then accept the invite, otherwise returns an error
- (void)acceptInviteWithCompletionHandler:(void(^__nullable)(GKTurnBasedMatch * __nullable match, NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 5_0) __WATCHOS_AVAILABLE(3_0);
// If the local participant has status invited then decline the invite, otherwise returns an error
- (void)declineInviteWithCompletionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 5_0) __WATCHOS_AVAILABLE(3_0);
// Remove a declined or completed match (one with a matchOutcome set) from the player's list of matches. If using the GKTurnBasedMatchmakerViewController UI, this will remove it from the finished sessions. The developer should not do this without user input.
- (void)removeWithCompletionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler;
// This method fetches the match data and exchanges for this match. This data is the state of the game at this point in time. This may update the status and/or participant properties if they have changed.
- (void)loadMatchDataWithCompletionHandler:(void(^__nullable)(NSData * __nullable matchData, NSError * __nullable error))completionHandler;
// Ends the current player's turn. You may update the matchOutcome for any GKTurnBasedPlayerInfos that you wish to before ending the turn.
// This will asynchronously report error in these cases:
// 1. Communications problem
// 2. Is not current player's turn
// 3. Session is closed
- (void)endTurnWithNextParticipants:(NSArray<GKTurnBasedParticipant *> *)nextParticipants
turnTimeout:(NSTimeInterval)timeout
matchData:(NSData*)matchData
completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_9, 6_0) __WATCHOS_AVAILABLE(3_0);
// Ends the current player's turn by quitting the match. The caller must indicate the next player and pass in updated matchData (if used). All completed exchanges must be resolved or canceled before calling this.
- (void)participantQuitInTurnWithOutcome:(GKTurnBasedMatchOutcome)matchOutcome
nextParticipants:(NSArray<GKTurnBasedParticipant *> *)nextParticipants
turnTimeout:(NSTimeInterval)timeout
matchData:(NSData*)matchData
completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_9, 6_0) __WATCHOS_AVAILABLE(3_0);
// Abandon the match when it is not the current participant's turn. In this there is no update to matchData and no need to set nextParticipant.
- (void)participantQuitOutOfTurnWithOutcome:(GKTurnBasedMatchOutcome)matchOutcome withCompletionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler;
// This will end the match for all participants. You must set each participant’s matchOutcome before calling this method. All completed exchanges must be resolved or canceled before calling this.
- (void)endMatchInTurnWithMatchData:(NSData*)matchData completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler;
// This will end the match and submit scores and achievements for all participants. Scores should be submitted for all involved players, and multiple scores may be submitted for each to different leaderboards. Earned achievements may also be submitted for any participants. You must set each participant’s matchOutcome before calling this method. All completed exchanges must be resolved or canceled before calling this.
- (void)endMatchInTurnWithMatchData:(NSData*)matchData scores:(nullable NSArray<GKScore *> *)scores achievements:(nullable NSArray<GKAchievement *> *)achievements completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// saves the matchData for the current turn without ending the turn. If other players have the game running they will receive a handleTurnEventForMatch to indicate that the matchData has changed. This is useful to initialize the game state for the first player when they take their turn or for updating the turn data due to the user taking an irreversible action within their turn. All completed exchanges must be resolved or canceled before calling this. If you are using exchanges use saveMergedMatchData instead.
- (void)saveCurrentTurnWithMatchData:(NSData *)matchData completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_8, 6_0) __WATCHOS_AVAILABLE(3_0);
// saves the merged matchData for the current turn without ending the turn and mark the supplied exchanges as resolved meaning that the data has been merged into the match data. If other players have the game running they will receive a handleTurnEventForMatch to indicate that the matchData has changed. It is required that all completed exchanges are resolved before ending a turn. Otherwise calling endTurn, participantQuitInTurnWithOutCome or endMatchInTurn will return an error
- (void)saveMergedMatchData:(NSData *)matchData
withResolvedExchanges:(NSArray<GKTurnBasedExchange *> *)exchanges
completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// Send an exchange request to one or more participants. Each recipient will receive a push notification using supplied localizable message. If any of the participants have an inactive status (GKTurnBasedParticipantStatusDone) then this will return an error. completionHandler gets passed the updated exchange with identifier, sender and recipients set
- (void)sendExchangeToParticipants:(NSArray<GKTurnBasedParticipant *> *)participants
data:(NSData *)data
localizableMessageKey:(NSString *)key
arguments:(NSArray<NSString *> *)arguments
timeout:(NSTimeInterval)timeout
completionHandler:(void(^__nullable)(GKTurnBasedExchange * __nullable exchange, NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// Send a reminder to one or more participants. Each recipient will receive a push notification using supplied localizable message. This allows a game to send reminders that a turn or exchange request needs action. On the receiver side this will generate a turn event for the match.
- (void)sendReminderToParticipants:(NSArray<GKTurnBasedParticipant *> *)participants
localizableMessageKey:(NSString *)key
arguments:(NSArray<NSString *> *)arguments
completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// deprecated methods
- (void)endTurnWithNextParticipant:(GKTurnBasedParticipant *)nextParticipant matchData:(NSData*)matchData completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_DEPRECATED(10_8, 10_9, 5_0, 6_0, "Use endTurnWithNextParticipants:... instead") ;
- (void)participantQuitInTurnWithOutcome:(GKTurnBasedMatchOutcome)matchOutcome nextParticipant:(GKTurnBasedParticipant *)nextParticipant matchData:(NSData*)matchData completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_DEPRECATED(10_8, 10_9, 5_0, 6_0, "Use participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:... instead") ;
@end
// Turn Based Exchanges
// Constants that describe the status of exchanges and their replies
typedef NS_ENUM(int8_t, GKTurnBasedExchangeStatus) {
GKTurnBasedExchangeStatusUnknown = 0,
GKTurnBasedExchangeStatusActive = 1,
GKTurnBasedExchangeStatusComplete = 2,
GKTurnBasedExchangeStatusResolved = 3,
GKTurnBasedExchangeStatusCanceled = 4
} NS_ENUM_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// Exchange timeout constants
extern NSTimeInterval GKExchangeTimeoutDefault NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0); // use a default timeout of one day
extern NSTimeInterval GKExchangeTimeoutNone NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
NS_CLASS_AVAILABLE(10_10,7_0) __WATCHOS_AVAILABLE(3_0)
@interface GKTurnBasedExchange : NSObject
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSString *exchangeID; // persistent identifier used to refer to this exchange.
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) GKTurnBasedParticipant *sender; // participant who sent the exchange
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedParticipant *> *recipients; // participants who are the recipients of the exchange
@property (assign, readonly, NS_NONATOMIC_IOSONLY) GKTurnBasedExchangeStatus status; // status of the exchange
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSString *message; // localized message for the push notification sent to all recipients of this exchange
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSData *data; // data to send with the exchange.
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSDate *sendDate; // send date for the exchange.
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSDate *timeoutDate; // timeout date for the exchange.
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSDate *completionDate; // date when this exchange completed
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSArray<GKTurnBasedExchangeReply *> *replies; // Array of GKTurnBasedExchangeReply.
// cancel an exchange. It is possible to cancel an exchange that is active or complete. Each recipient will receive a push notification using supplied localizable message. Returns an error if the exchange has already been canceled.
- (void)cancelWithLocalizableMessageKey:(NSString *)key arguments:(NSArray<NSString *> *)arguments completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
// reply to an exchange. The sender will receive a push notification using supplied localizable message. Returns an error if the exchange has already been canceled.
- (void)replyWithLocalizableMessageKey:(NSString *)key arguments:(NSArray<NSString *> *)arguments data:(NSData *)data completionHandler:(void(^__nullable)(NSError * __nullable error))completionHandler NS_AVAILABLE(10_10, 7_0) __WATCHOS_AVAILABLE(3_0);
@end
NS_CLASS_AVAILABLE(10_10,7_0) __WATCHOS_AVAILABLE(3_0)
@interface GKTurnBasedExchangeReply : NSObject
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) GKTurnBasedParticipant *recipient; // the recipient who this reply is from
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSString *message; // localized message for the push notification generated by the reply of this exchange
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSData *data; // data sent by the replying recipient
@property (readonly, nullable, NS_NONATOMIC_IOSONLY) NSDate *replyDate NS_AVAILABLE(10_10, 8_0) __WATCHOS_AVAILABLE(3_0); // send date for the exchange.
@end
// deprecated
// see documentation for GKTurnBasedEventListener for the equivalent methods
NS_DEPRECATED(10_8, 10_10, 5_0, 7_0, "Use registerListener on GKLocalPlayer with an object that implements the GKTurnBasedEventListener protocol")
@protocol GKTurnBasedEventHandlerDelegate
- (void)handleInviteFromGameCenter:(NSArray<NSString *> *)playersToInvite NS_DEPRECATED(10_8, 10_10, 5_0, 7_0);
- (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive NS_DEPRECATED(10_9, 10_10, 6_0, 7_0);
@optional
- (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match NS_DEPRECATED(10_8, 10_9, 5_0, 7_0);
- (void)handleMatchEnded:(GKTurnBasedMatch *)match NS_DEPRECATED(10_8, 10_10, 6_0, 7_0);
@end
NS_CLASS_DEPRECATED(10_8, 10_10, 5_0, 7_0, "Use registerListener on GKLocalPlayer with an object that implements the GKTurnBasedEventListener protocol")
@interface GKTurnBasedEventHandler : NSObject
+ (GKTurnBasedEventHandler *)sharedTurnBasedEventHandler NS_DEPRECATED(10_8, 10_10, 5_0, 7_0);
@property (assign, NS_NONATOMIC_IOSONLY) NSObject<GKTurnBasedEventHandlerDelegate> *delegate NS_DEPRECATED(10_8, 10_10, 5_0, 7_0);
@end
NS_ASSUME_NONNULL_END
// ========== GameKit.framework/Headers/GKLeaderboard.h
//
// GKLeaderboard.h
// Game Center
//
// Copyright 2010-2019 Apple Inc. All rights reserved.
//