-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add the installation id on ios as well
- Loading branch information
1 parent
f8ceabd
commit e413cd9
Showing
3 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// ClientWrapper.swift | ||
// XMTPReactNative | ||
// | ||
// Created by Naomi Plasterer on 6/10/24. | ||
// | ||
|
||
import Foundation | ||
import XMTP | ||
|
||
// Wrapper around XMTP.Client to allow passing these objects back into react native. | ||
struct ClientWrapper { | ||
static func encodeToObj(_ client: XMTP.Client) throws -> [String: Any] { | ||
return [ | ||
"inboxId": client.inboxID, | ||
"address": client.address, | ||
"installationId": client.installationID, | ||
] | ||
} | ||
|
||
static func encode(_ client: XMTP.Client) throws -> String { | ||
let obj = try encodeToObj(client) | ||
let data = try JSONSerialization.data(withJSONObject: obj) | ||
guard let result = String(data: data, encoding: .utf8) else { | ||
throw WrapperError.encodeError("could not encode client") | ||
} | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters