Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Merge requests
!4
Add basic usage examples
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add basic usage examples
feature/basic-docs
into
main
Overview
0
Commits
3
Pipelines
0
Changes
1
Merged
Dariusz Rybicki
requested to merge
feature/basic-docs
into
main
2 years ago
Overview
0
Commits
3
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
version 1
version 1
b67c1871
2 years ago
main (base)
and
latest version
latest version
57d1ed3a
3 commits,
2 years ago
version 1
b67c1871
1 commit,
2 years ago
Show latest version
1 file
+
3
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
README.md
+
142
−
1
Options
#
e
lixxir
-dapps-sdk-swift
#
E
lixxir
dApps Swift SDK


@@ -9,6 +9,147 @@ Add `ElixxirDAppsSDK` library as a dependency to your project using Swift Packag
For usage examples, checkout included example iOS application.
### ▶️ Instantiating client
Create a new client and store it on disk:
```
swift
let
downloadNDF
:
NDFDownloader
=
.
live
let
createClient
:
ClientCreator
=
.
live
try
createClient
(
directoryURL
:
...
,
ndf
:
try
downloadNDF
(
.
mainnet
),
password
:
...
)
```
Load existing client from disk:
```
swift
let
loadClient
:
ClientLoader
=
.
live
let
client
=
try
loadClient
(
directoryURL
:
...
,
password
:
...
)
```
You can also use a convenient
`ClientStorage`
wrapper to manage a client stored on disk:
```
swift
let
storage
:
ClientStorage
=
.
live
(
passwordStorage
:
.
init
(
save
:
{
password
in
// securely save provided client's password
},
load
:
{
// load securely stored client's password
}
)
)
let
client
:
Client
if
storage
.
hasStoredClient
()
{
client
=
try
storage
.
loadClient
()
}
else
{
client
=
try
storage
.
createClient
()
}
```
Check out included example iOS application for the
`PasswordStorage`
implementation that uses the iOS keychain.
### ▶️ Connecting to the network
Start network follower:
```
let client: Client = ...
try client.networkFollower.start(timeoutMS: 10_000)
```
Wait until connected:
```
let client: Client = ...
let isNetworkHealthy = client.waitForNetwork(timeoutMS: 30_000)
```
### ▶️ Making a new identity
Use the client to make a new identity:
```
swift
let
client
:
Client
=
...
let
myIdentity
=
try
client
.
makeIdentity
()
```
### ▶️ Connecting to remote
Perform auth key negotiation with the given recipient to get the
`Connection`
:
```
swift
let
client
:
Client
=
...
let
connection
=
try
client
.
connect
(
withAuthentication
:
false
,
recipientContact
:
...
,
myIdentity
:
...
)
```
Pass
`true`
for the
`withAuthentication`
parameter if you want to prove id ownership to remote as well.
### ▶️ Sending messages
Send a message to the connection's partner:
```
swift
let
connection
:
Connection
=
...
let
report
=
try
connection
.
send
(
messageType
:
1
,
payload
:
...
)
```
Check if the round succeeded:
```
swift
let
client
:
Client
=
...
try
client
.
waitForDelivery
(
roundList
:
...
,
timeoutMS
:
30_000
)
{
result
in
switch
result
{
case
.
delivered
(
let
roundResults
):
...
case
.
notDelivered
(
let
timedOut
):
...
}
}
```
### ▶️ Receiving messages
Use connection's message listener to receive messages from partner:
```
swift
let
connection
:
Connection
=
...
connection
.
listen
(
messageType
:
1
)
{
message
in
...
}
```
### ▶️ Using rest-like API
Use
`RestlikeRequestSender`
to perform rest-like requests:
```
swift
let
client
:
Client
=
...
let
connection
:
Connection
=
...
let
sendRestlike
:
RestlikeRequestSender
=
.
live
(
authenticated
:
false
)
let
response
=
try
sendRestlike
(
clientId
:
client
.
getId
(),
connectionId
:
connection
.
getId
(),
request
:
...
)
```
Pass
`true`
for the
`authenticated`
parameter if you want to perform authenticated requests.
## 🛠 Development
Open
`ElixxirDAppsSDK.xcworkspace`
in Xcode (≥13.4).
Loading