Skip to content

dctrue/tga-sdk-bundle-ios

Repository files navigation

TGASDK

Xcode - Build and Analyze languages Swift CocoaPods Compatible Platform

中文介绍

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 5.0+

Installation

TGASDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TGASDK'

Usage Swift

import TGASDK

Config TGASDK

TGASdk.shared.configuration.lang = "\(Locale.current.languageCode ?? "")"
TGASdk.shared.configuration.statusBarStyle = .lightContent
TGASdk.shared.configuration.navigationBackImage = UIImage()

Print Log

TGASdk.shared.setLogLevel(level: .all)

Init TGASDK

// env: default is empty
// appkey: SDK key to use for the instance of the TGASDK SDK
// userInfo: user information userId, userName, avatar
TGASdk.shared.initSdk(env: nil, appKey: "", userInfo: nil, delegate: self)

Open GameCenter

TGASdk.shared.openGameCenter(secUrl: "", secTitle: "")

Logout

TGASdk.shared.logout()

Delegate

func tgaSdkInitSucceed() {
   debugPrint("init Succeed")
}

func tgaSdkInitError(_ error: NSError) {
    debugPrint("init failure\(error.localizedDescription)")
}

func tgaSdkOnLogout() {
   debugPrint("sdk User logout")
}

func tgaSdkCloseGameCenter() {
   debugPrint("close game Controller")
}

func tgaSdkGetUserInfo(completion: @escaping ((TGAUserInfo?) -> Void)) {
   debugPrint("TGAUserInfo: user information userId, userName, avatar")
}

Usage objc

#import "TGASDK/TGASDK-Swift.h"

Config TGASDK

// TGASDK config attribute
TGASdk.shared.configuration.lang = [NSLocale currentLocale].languageCode;
TGASdk.shared.configuration.statusBarStyle = UIStatusBarStyleLightContent;
TGASdk.shared.configuration.navigationBackImage = [UIImage imageNamed:@"navigation_back_default"];

Init TGASDK

[TGASdk.shared initSdkWithEnv:nil appKey:@"" userInfo:nil delegate:self];

Open GameCenter

[TGASdk.shared openGameCenterWithSecUrl:nil secTitle:nil];

Logout

[TGASdk.shared logout];

Delegate

-(void)tgaSdkInitSucceed {
    NSLog(@"register success");
}

-(void)tgaSdkInitError:(NSError *)error {
    NSLog(@"%@", [[NSString alloc] initWithFormat:@"%@%@", @"error reason: ", error.localizedDescription]);
}

-(void)tgaSdkOnLogout {
    NSLog(@"sdk User logout")
}

-(void)tgaSdkCloseGameCenter {
    NSLog(@"close game Controller");
}

-(void)tgaSdkGetUserInfoWithCompletion:(void (^ _Nonnull)(TGAUserInfo * _Nullable))completion {
    NSLog(@"TGAUserInfo: user information userId, userName, avatar")
}

License

TGASDK is available under the Apache2.0 License. See the LICENSE file for more info.