@@ -166,9 +166,16 @@ @implementation PhoneListenerDataObjC
166
166
FIREBASE_ASSERT (future_api != nullptr );
167
167
168
168
const auto handle = future_api->SafeAlloc <Credential>(kCredentialFn_GameCenterGetCredential );
169
+ /* *
170
+ Linking GameKit.framework without using it on macOS results in App Store rejection.
171
+ Thus we don't link GameKit.framework to our SDK directly. `optionalLocalPlayer` is used for
172
+ checking whether the APP that consuming our SDK has linked GameKit.framework. If not, will
173
+ complete with kAuthErrorInvalidCredential error.
174
+ **/
175
+ GKLocalPlayer *_Nullable optionalLocalPlayer = [[NSClassFromString (@" GKLocalPlayer" ) alloc ] init ];
169
176
170
177
// Early-out if GameKit is not linked
171
- if ([GKLocalPlayer class ] == nullptr ) {
178
+ if (!optionalLocalPlayer ) {
172
179
future_api->Complete (handle, kAuthErrorInvalidCredential ,
173
180
" GameCenter authentication is unavailable - missing GameKit capability." );
174
181
return MakeFuture (future_api, handle);
@@ -197,11 +204,18 @@ @implementation PhoneListenerDataObjC
197
204
198
205
// static
199
206
bool GameCenterAuthProvider::IsPlayerAuthenticated () {
207
+ /* *
208
+ Linking GameKit.framework without using it on macOS results in App Store rejection.
209
+ Thus we don't link GameKit.framework to our SDK directly. `optionalLocalPlayer` is used for
210
+ checking whether the APP that consuming our SDK has linked GameKit.framework. If not,
211
+ early out.
212
+ **/
213
+ GKLocalPlayer *_Nullable optionalLocalPlayer = [[NSClassFromString (@" GKLocalPlayer" ) alloc ] init ];
200
214
// If the GameKit Framework isn't linked - early out.
201
- if ([GKLocalPlayer class ] == nullptr ) {
215
+ if (!optionalLocalPlayer ) {
202
216
return false ;
203
217
}
204
- GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer ];
218
+ __weak GKLocalPlayer *localPlayer = [[optionalLocalPlayer class ] localPlayer ];
205
219
return localPlayer.isAuthenticated ;
206
220
}
207
221
0 commit comments