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
Commits
f0fd6e35
Commit
f0fd6e35
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md
parent
bd056c99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!102
Release 1.0.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+42
-76
42 additions, 76 deletions
README.md
with
42 additions
and
76 deletions
README.md
+
42
−
76
View file @
f0fd6e35
...
...
@@ -13,54 +13,31 @@ Also you can checkout included example iOS application.
You can find full documentation with step by step guide
[
here
](
https://xxdk-dev.xx.network/mobile%20docs/ios-sdk
)
## 🚀 Quick Start
Add
`ElixxirDAppsSDK`
library as a dependency to your project using Swift Package Manager.
### ▶️ Instantiating cMix
### ▶️ 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:
You can use a convenient
`CMixManager`
wrapper to manage cMix stored on 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
(
let
cMixManager
:
CMixManager
=
.
live
(
passwordStorage
:
.
init
(
save
:
{
password
in
// securely save provided
client's
password
// securely save provided password
},
load
:
{
// load securely stored
client's
password
// load securely stored password
}
)
)
let
client
:
Client
if
storage
.
hasStoredClient
()
{
client
=
try
storage
.
loadClient
()
let
cMix
:
CMix
if
cMixManager
.
hasStorage
()
{
cMix
=
try
cMixManager
.
load
()
}
else
{
c
lient
=
try
stor
age
.
create
Client
()
c
Mix
=
try
cMixMan
age
r
.
create
()
}
```
...
...
@@ -71,30 +48,34 @@ Check out included example iOS application for the `PasswordStorage` implementat
Start network follower:
```
let c
lient: Client
= ...
try c
lient.n
etworkFollower
.start
(timeoutMS: 10_000)
let c
Mix: CMix
= ...
try c
Mix.startN
etworkFollower(timeoutMS: 10_000)
```
Wait until connected:
```
let c
lient: Client
= ...
let isNetworkHealthy =
client
.waitForNetwork(timeoutMS: 30_000)
let c
Mix: CMix
= ...
let isNetworkHealthy =
try cMix
.waitForNetwork(timeoutMS: 30_000)
```
### ▶️ Making a new identity
### ▶️ Making a new
reception
identity
Use the c
lient
to make a new identity:
Use the c
Mix
to make a new
reception
identity:
```
swift
let
c
lient
:
Client
=
...
let
myIdentity
=
try
c
lient
.
make
Identity
()
let
c
Mix
:
CMix
=
...
let
myIdentity
=
try
c
Mix
.
makeReception
Identity
()
```
### ▶️ Create new E2E client
### ▶️ Create new E2E
```
swift
let
client
:
Client
=
...
let
clientE2E
=
try
ClientE2ELogin
.
live
(
with
:
client
)
let
login
:
Login
=
.
live
let
e2e
=
try
login
(
cMixId
:
cMix
.
getId
(),
identity
:
myIdentity
)
```
### ▶️ Connecting to remote
...
...
@@ -102,12 +83,10 @@ let clientE2E = try ClientE2ELogin.live(with: client)
Perform auth key negotiation with the given recipient to get the
`Connection`
:
```
swift
let
client
:
Client
=
...
let
clientE2E
:
ClientE2E
=
...
let
connection
=
try
client
.
connect
(
let
connection
=
try
cMix
.
connect
(
withAuthentication
:
false
,
recipientContact
:
...
,
e2eId
:
clientE2E
.
getId
()
e2eId
:
e2e
.
getId
(),
recipientContact
:
...
)
```
...
...
@@ -118,9 +97,8 @@ Pass `true` for the `withAuthentication` parameter if you want to prove id owner
Send a message to the connection's partner:
```
swift
let
connection
:
Connection
=
...
let
report
=
try
connection
.
send
(
messageType
:
1
,
let
sendReport
=
try
connection
.
send
(
messageType
:
1
,
payload
:
...
)
```
...
...
@@ -128,15 +106,18 @@ let report = try connection.send(
Check if the round succeeded:
```
swift
let
client
:
Client
=
...
try
client
.
waitForDelivery
(
roundList
:
...
,
timeoutMS
:
30_000
)
{
result
in
switch
result
{
try
cMix
.
waitForMessageDelivery
(
report
:
sendReport
,
timeoutMS
:
30_000
,
callback
:
.
init
{
result
in
switch
result
{
case
.
delivered
(
let
roundResults
):
...
case
.
notDelivered
(
let
timedOut
):
...
}
}
}
)
```
### ▶️ Receiving messages
...
...
@@ -144,29 +125,14 @@ try client.waitForDelivery(roundList: ..., timeoutMS: 30_000) { result in
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
:
...
try
connection
.
registerListener
(
messageType
:
1
,
listener
:
.
init
{
message
in
...
}
)
```
Pass
`true`
for the
`authenticated`
parameter if you want to perform authenticated requests.
## 🛠 Development
Open
`ElixxirDAppsSDK.xcworkspace`
in Xcode (≥13.4).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment