zoukankan      html  css  js  c++  java
  • IOS GameCenter验证登陆

    #import "GameKitHelper.h"
    #import "GameConstants.h"
    
    @interface GameKitHelper ()
            <GKGameCenterControllerDelegate> {
        BOOL _gameCenterFeaturesEnabled;
    }
    @end
    
    @implementation GameKitHelper
    
    #pragma mark Singleton stuff
    
    +(id) sharedGameKitHelper {
        static GameKitHelper *sharedGameKitHelper;
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            sharedGameKitHelper =
                    [[GameKitHelper alloc] init];
        });
        return sharedGameKitHelper;
    }
    
    #pragma mark Player Authentication
    
    -(void) authenticateLocalPlayer {
    
      GKLocalPlayer* localPlayer =
        [GKLocalPlayer localPlayer];
    
        localPlayer.authenticateHandler =
        ^(UIViewController *viewController,
          NSError *error) {
    
            [self setLastError:error];
    
            if ([CCDirector sharedDirector].isPaused)
                [[CCDirector sharedDirector] resume];
    
            if (localPlayer.authenticated) {
                _gameCenterFeaturesEnabled = YES;
            } else if(viewController) {
                [[CCDirector sharedDirector] pause];
                [self presentViewController:viewController];
            } else {
                _gameCenterFeaturesEnabled = NO;
            }
        };
    }
    @end


    #pragma mark Property setters
    
    -(void) setLastError:(NSError*)error {
        _lastError = [error copy];
        if (_lastError) {
            NSLog(@"GameKitHelper ERROR: %@", [[_lastError userInfo] 
              description]);
        }
    }
    
    #pragma mark UIViewController stuff
    
    -(UIViewController*) getRootViewController {
        return [UIApplication 
          sharedApplication].keyWindow.rootViewController;
    }
    
    -(void)presentViewController:(UIViewController*)vc {
        UIViewController* rootVC = [self getRootViewController];
        [rootVC presentViewController:vc animated:YES 
          completion:nil];
    }
  • 相关阅读:
    vue 虚拟列表
    图片验证
    md5 文件上传
    js中apply方法的使用
    js通过replace()方法配合正则去除空格
    使用bind()方法扩充作用域
    取数组最大最小值得方法
    css穿透点击
    为什么选择器li#id名/li.类名的写法
    子元素与父元素等高
  • 原文地址:https://www.cnblogs.com/zxhl/p/9796680.html
Copyright © 2011-2022 走看看