iOS SDK

This document explains how to use the GAMEPOT iOS SDK for game development on iOS. By installing the SDK and configuring the environment, you can integrate the game with the

System Requirements

The following are the system requirements for using the GAMEPOT iOS SDK:

  • Minimum requirement: iOS 15 or higher (If support for lower iOS versions is needed, please contact [email protected].)

SDK Installation and Environment Configuration

After installing the iOS SDK, configure the environment to integrate the GAMEPOT dashboard with the game and use the necessary features for game development.

The languages supported by the GAMEPOT SDK are as follows:

  • Korean, English, Italian, Thai, Vietnamese, Japanese, Chinese (Simplified/Traditional), Indonesian, German, Spanish, French.

When the app is run, the supported language will be displayed according to the device's language. If a language is not supported, it will default to English.

SDK Installation

To install the GAMEPOT iOS SDK and set up the project, follow these steps

  1. Log in to the dashboard with an administrator account.

  2. In the iOS project folder, create a Podfile using CocoaPods.

pod init
  1. Add the NBase SDK to the Podfile. Please refer to the "Podfile Configuration" section below for the Podfile definitions.

  2. Install the NBase SDK via CocoaPods.

pod install

COCOAPODS

For the iOS SDK, you must install CocoaPods for a successful installation.

Podfile Configuration

Open the Podfile with a text editor and add the necessary frameworks for the GAMEPOT SDK.

platform :ios, '15.0'

# Project Main Target
target 'Project Main Target' do
...
  pod 'Alamofire', '5.8.1'
  pod 'Apollo', '1.14.1'
  pod 'Socket.IO-Client-Swift', '16.1.0'
  pod 'AppAuth', '1.6.2'
  pod 'SDWebImage', '5.19.1'
  pod 'NBase', '3.0.51'
...
end

Example: If using Google login and Facebook login.

platform :ios, '15.0'

target 'GAMEPOT_GAME' do
 use_frameworks!

 # Pods for Nbase SDK
 pod 'Alamofire', '5.8.1'
 pod 'Apollo', '1.14.1'
 pod 'Socket.IO-Client-Swift', '16.1.0'
 pod 'AppAuth', '1.6.2'
 pod 'SDWebImage', '5.19.1'
 pod 'NBase', '3.0.51'
 pod 'NBaseAdapterProviderGoogle', '3.0.1'
 pod 'NBaseAdapterProviderFacebook', '3.0.51'
end
Name
Version
Type
Dependeny modules

NBase

3.0.51

GAMEPOT Base Module

X

NBaseAdapterProviderGoogle

3.0.1

Google Login

NBaseAdapterProviderFacebook

3.0.51

Facebook Login

FBSDKLoginKit (16.3.1)

NBaseAdapterProviderNaver

3.0.1

NAVER Login

NBaseAdapterProviderLine

3.0.1

Line Login

NBaseAdapterProviderX

3.0.1

X Login

For email, Apple, and guest logins, they are applied to the base module.

Adding Apollo Package Manager

If the error "No such module 'Apollo'" occurs, please run the Swift Package Manager and add the Apollo framework.

Click the '+' button, then add the package collection 'https://github.com/apollographql/apollo-ios.git', select apollo-ios, and then choose the main project target in the Add Package section.

Preparation

  1. You can copy the Project ID and Project Key from the Dashboard → Project Settings.

  2. Environment settings for login, store, and integration can all be added/modified from the Dashboard → Project Settings.

  3. For each login method, refer to the [Login Authentication Settings], configure it in the console, and add it to the dashboard.

  4. For in-app payments, refer to the [Store Settings], configure it in the console, and add it to the dashboard.

  5. Please register items for in-app payments in each store. Add them in the Dashboard → Payment → In-App section.

Initialization

To initialize, add the following code to the object used in the first scene that loads when the game starts.

import NBase

NBase.initialize([projectId], projectKey: [projectKey], storeId: [storeId], language: [language], region: [region]) { result in
    switch result {
    case .success(let data):
        NBase.showToast(message: data?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}
  • Parameter

Key
Description
Required

projectId

Dashboard → Project Settings

O

projectKey

shboard → Project Settings

O

storeId

Store (apple, google)

O

language

Language (en,ko,jp ...)

O

region

Region (kr, jp, sg, us, eu, preview)

O

  • Callback

Key
Type
Description

status

Bool

Status

language

String

Language

country

String

Country

remote_ip

String

IP

platform

String

Platform

sandbox

Bool

Sandbox Status

Login

To use the SDK login functionality that is triggered when the login button is clicked, depending on the login UI implemented by the developer, please use the following code.

NBase.signIn(serviceType: .google) { result in
    switch result {
    case .success(let data):
        NBase.showToast(message: data?.encodeToJson() ?? "")
        break
    case .failure(let error):
        if let nBaseError = error as? NBaseError {
            switch nBaseError {
            case .noMaintenance:  // Maintenance
                NBase.showToast(message: error.localizedDescription)
            case .noUpdated : // Update
                NBase.showToast(message: error.localizedDescription)
            default:
                print("An unknown error occurred: \(error)")
                NBase.showToast(message: error.localizedDescription)
            }
        } else {
            print("An error occurred: \(error)")
            NBase.showToast(message: error.localizedDescription)
        }
    }
}
  • Parameter

Key
Description

SignInServiceType.google

Google

SignInServiceType.anonymous

Guest

SignInServiceType.facebook

Facebook

SignInServiceType.apple

Apple

SignInServiceType.kakao

Kakao

SignInServiceType.x

X

SignInServiceType.line

Line

SignInServiceType.naver

NAVER

SignInServiceType.github

Github

SignInServiceType.microsoft

Microsoft

SignInServiceType.huawei

Huawei

  • Callback

Key
Type
Description

id

String

User ID

name

String

User Name

nickname

String

User Nickname

email

String

Email

token

String

Token

age

Int

Age

birth

String

Date of Birth

sex

String

Gender

profile

String

Profile URL

mobile

String

Phone Number

Automatic Login (Optional)

After initialization, the system attempts automatic login using the last authentication method the user logged in with.

NBase.signInLastLoggedIn(completionHandler: { result in
    switch result {
    case .success(let data):
        NBase.showToast(message: data?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
})

Self-ID and Password Authentication (Optional)

This authentication method allows users to log in using their email address and password. It performs user authentication based on the user's email address and password. This feature plays an important role in traditional email/password-based authentication systems.

NBase.signInWithPassword(username: [username], password: [password], options: [option]) { result in
    switch result {
    case .success(let user):
        NBase.showToast(message: user?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}

Logout

To use the SDK logout function, please use the code below.

NBase.signOut() { result in
    switch result {
    case .success(let status):
        NBase.showToast(message: "signOut \((status != nil) ? "true" : "false")")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}
  • Callback

Key
Type
Description

status

Bool

Success Status

Payment

Before making a payment, you must configure the settings for each store according to the store's requirements in the [Store Settings].

Additionally, if items have not been added in the Dashboard → Payment → In-App section, the error 'ProductID not found' will occur.

Fetch In-App Information

When making a payment, you need to display payment information and local currency details on the screen. You can retrieve the current payment currency, name, and other details using the functions below. If the information is not fetched correctly, please check the console settings.

let products = NBase.getProductItems()
  • Callback

Key
Type
Description

id

String

Product ID

name

String

Product Name

currency

String

Currency

price

Float64

Product Price

localizedPrice

String

Localized Price

description

String

Product Description

Payment Request

You can request a payment using the productId from the fetched in-app information.

NBase.purchase(productId: [productId], metadata: [metadata], options: [options]) { result in
    switch result {
    case .success(let data):
        NBase.showToast(message: data?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}
  • Parameter

Key
Description
Required

productId

Product ID (Dashboard → Payment → IAP)

O

metadata

Metadata

X

options

결Payment Option Features

X

  • Callback

Key
Type
Description

orderId

String

Order ID

receipt

String

Receipt

signature

String

Signature

productId

String

Product ID

storeId

String

Store ID

country

String

Country

quantity

Int

Quantity

paymentId

String

Payment ID

currency

String

Currency

serverId

String

Server ID

playerId

String

Player ID

userdata

String

User Data

metadata

String

Metadata

options

String

Payment Options

authCode

String

Authentication Code

level

Int

Level

price

Float64

Price

Troubleshooting

Q. Authorization failed: Error Domain=AKAuthenticationError Code=-7026 A. Click on TARGETS > +Capability to add Sign in with Apple.

Last updated