Keychain
Key
Key ตั้งต้นสำหรับการเก็บค่าลง Keychain ภายในแอพพลิเคชัน
public enum Key: String {
case oAuthAccessToken
case oAuthExpiredTimestamp
case oAuthRefreshToken
case language
case userInfo
case fcmToken
case passcode
}
| Name | Description |
|---|
| oAuthAccessToken | Key ของ Access Token สำหรับการยิง Request |
| oAuthExpiredTimestamp | Key ของ Timestamp ที่ Access Token จะหมดอายุ |
| oAuthRefreshToken | Key ของ Refresh Token |
| language | Key ของภาษา (ใช้สำหรับแอพพลิเคชันที่รองรับมากกว่า 1 ภาษา) |
| userInfo | Key ของข้อมูลผู้ใช้งาน |
| fcmToken | Key ของ fcmToken (ใช้สำหรับแอพพลิเคชันที่มีการใช้ Firebase cloud messaging) |
| passcode | Key ของ Passcode (ใช้สำหรับแอพพลิเคชันที่มีการตั้ง Passcode) |
Method Overview
| Name | Description | Return |
|---|
| getData() | รับข้อมูล Data จาก Keychain ด้วย Key | Optional(Data) |
| set() | บันทึกข้อมูล Data ใน Keychain ด้วย Key | void |
| remove() | ลบข้อมูล Data ใน Keychain ด้วย Key | void |
Method Details
public func getData(key: Key) -> Data?
รับข้อมูล Data จาก Keychain ด้วย Key
Parameters
| Name | Description | Type |
|---|
| key | Key ของข้อมูลที่จะดึงจาก Keychain | Key |
Returns
| Type | Description |
|---|
| Optional(Data) | Return ข้อมูลที่บันทึกอยู่ใน Keychain |
public func getData(key: String) -> Data?
รับข้อมูล Data จาก Keychain ด้วย Key ที่เป็น String
Parameters
| Name | Description | Type |
|---|
| key | Key ของข้อมูลที่จะดึงจาก Keychain | String |
Returns
| Type | Description |
|---|
| Optional(Data) | Return ข้อมูลที่บันทึกอยู่ใน Keychain |
public func set(data: Data, key: Key) throws
บันทึกข้อมูล Data ใน Keychain ด้วย Key
Parameters
| Name | Description | Type |
|---|
| data | ข้อมูลที่ต้องการบันทึกลงใน Keychain | Data |
| key | Key ของข้อมูลที่จะเก็บลงใน Keychain | Key |
public func set(_ text: String, key: Key) throws
บันทึกข้อมูล text ใน Keychain ด้วย Key
Parameters
| Name | Description | Type |
|---|
| text | ข้อความที่ต้องการบันทึกลงใน Keychain | String |
| key | Key ของข้อมูลที่จะเก็บลงใน Keychain | Key |
public func set(data: Data, key: String) throws
บันทึกข้อมูล Data ใน Keychain ด้วย Key ที่เป็น String
Parameters
| Name | Description | Type |
|---|
| data | ข้อมูลที่ต้องการบันทึกลงใน Keychain | Data |
| key | Key ของข้อมูลที่จะเก็บลงใน Keychain | String |
public func set(_ text: String, key: String) throws
บันทึกข้อมูล text ใน Keychain ด้วย Key ที่เป็น String
Parameters
| Name | Description | Type |
|---|
| text | ข้อความที่ต้องการบันทึกลงใน Keychain | String |
| key | Key ของข้อมูลที่จะเก็บลงใน Keychain | String |
public func remove(_ key: Key) throws
ลบข้อมูลใน Keychain ด้วย Key
Parameters
| Name | Description | Type |
|---|
| key | Key ของข้อมูลที่จะลบใน Keychain | Key |
public func remove(_ key: String) throws
ลบข้อมูลใน Keychain ด้วย Key ที่เป็น String
Parameters
| Name | Description | Type |
|---|
| key | Key ของข้อมูลที่จะลบใน Keychain | String |