Swiftpack.co - Package - tkgstrator/SplatNet2

SplatNet2

SplatNet2 is the framework to generate iksm_session using internal and external API to get JSON from SplatNet2.

Installation

Requirements

  • iOS13.0+
  • Xcode 11+

CocoaPods

pod 'SplatNet2'

SPM(Swift Package Manager)

dependencies: [
    .package(url: "https://github.com/tkgstrator/SplatNet2.git")
]

Usage

session_token_code

Generating iksm_session, we must need session_token_code and session_token_code_verifier given by random byte strings. Moreover, session_token_code is provided by oauth_url like this.

This website could help you to get them. They(auth_url and auth_code_verifier) are reusable, you don't have to access twice.

get iksm_session

import SplatNet2
import SwiftyJSON

do {
    var response: JSON = JSON()
    let session_token_code = "YOUR SESSION TOKEN CODE"
    let session_token_code_verifier = "YOUR SESSION TOKEN CODE VERIFIER"
    response = try SplatNet2.getSessionToken(session_token_code, session_token_code_verifier)
    let session_token = response["session_token"].stringValue
    response = try SplatNet2.genIksmSession(session_token)
} catch (error) {
    // Error handling
}

regenerate iksm_session

Session token does not have the expiration, so it takes less time to regenarate iksm_session by session_token.

import SplatNet2
import SwiftyJSON

do {
    let session_token = "YOUR SESSION TOKEN"
    response = try SplatNet2.genIksmSession(session_token)
} catch (error) {
    // Error handling
}

nickname and icons

Nintendo provides the API to get nickname and icons by nsaid(this is named as nsa-data-id/pid/principal id).

import SplatNet2
import SwiftyJSON

do {
    let iksm_session = "YOUR IKSM SESSION"
    let nsaids: [String] = "NSAID's ARRAY"
    response = try SplatNet2.getPlayerNickname(nsaids, iksm_session)
} catch (error) {
    // Error handling
}

Error handling

SplatNet2 might return Error with below format in case Nintendo change API method.

enum APIError: Error {
    case Response(String, String)
}
  • 9400 Invalid request in getting Splatoon Access Token
  • 9002 Invalid/Expired Iksm Session (Need to regenerate)
  • 9403 Invalid token in getting Splatoon Token
  • 9406 OAuth session was Unauthorized (Nintendo API change X-ProductVersion?)
  • 9427 Upgrade Required (Nintendo Switch Online app update)
  • 9999 Unkonwn Error

Github

link
Stars: 0

Used By

Total: 0

Releases

0.1.5 - 2020-10-12 21:25:57

Update APPError

0.1.4 - 2020-10-12 19:17:07

Add UserAgent

0.1.3 - 2020-10-08 08:45:56

Add Initial Value

0.1.2 - 2020-10-07 13:30:29

Using X-Product Version for argument.

0.1.1 - 2020-10-07 11:30:28

Update READEME.md

0.1.0 - 2020-10-07 10:24:43

Replacement for Nintendo Official API

0.0.4 - 2020-09-30 07:24:15

0.0.3 - 2020-09-23 01:10:24

- 2020-09-22 21:21:48

0.0.2 - 2020-09-23 00:37:58