Integration
Swift
Installation
Add Avatars Swift package from git.
How it works
In order to make the Avatar SDK works in ios environment, we have built a simple frontend and wrap it up with WKWebView
.
All data input from ios app will be sent to the webview and takes effect after handling.
Therefore, please turn on Outgoing Connections (Client)
, otherwise webview will not work.
The Code
You need to first import the package and create a stateObject with AvatarViewModel()
. It contain various data for creating the AvatarView
.
Then you can create the AvatarView
in body with the stateObject to create the canvas.
Advance settings
Avatars Swift package also support avatar interaction incluing audio lip-sync and emotions.
References
AvatarViewModel
Field | Type | Description |
---|---|---|
avatarId | String | The id of the avatar you created. You can create you own avatar at here! |
x | Float | The position of the avatar on the x axis. |
y | Float | The position of the avatar on the y axis. |
scale | Float | The scale of the avatar. Default is set to ‘1’. |
rotation | Float | Set the value between 0 and 1 to rotate the avatar. |
currentEmotion | String | The emotion avatar is currently showing. Changing this value to make the avatar express emotion. Emotions the avatar can express is stored at availableEmotion . |
availableEmotion | String[] | An array of string containing all available emotion the avatar can express. Pass one of those string to currentEmotion will change the emotion. |
audioSource | String | The source of the audio, usually an Url. The audio will be played automatically once the value is changed. |
rawBase64Audio | String | The source of the audio which is encoded with Base64 format. Usually used with base64EncodedString() to encode the audio data. |