Created
March 24, 2021 19:56
-
-
Save jtmuller5/7ae34885d675fa7a374e1b3235b59f3a to your computer and use it in GitHub Desktop.
Create an AtClient
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
/// Create an AtClient (AtClientImpl) to communicate with the person's | |
/// secondary server | |
Future<bool> onboard({String atsign}) async { | |
atClientImpl = null; | |
atClientService = AtClientService(); | |
Directory downloadDirectory; | |
/// The directory where keys will be stored | |
if (Platform.isIOS) { | |
downloadDirectory = | |
await path_provider.getApplicationDocumentsDirectory(); | |
} | |
/// Download path varies on non-iOS platforms | |
else { | |
downloadDirectory = await path_provider.getExternalStorageDirectory(); | |
} | |
final appSupportDirectory = | |
await path_provider.getApplicationSupportDirectory(); | |
String path = appSupportDirectory.path; | |
/// Setup AtClient preferences (cascade for cleanliness) | |
atClientPreference = AtClientPreference() | |
..isLocalStoreRequired = true | |
..commitLogPath = path | |
..syncStrategy = SyncStrategy.IMMEDIATE | |
..rootDomain = AtConstants.ROOT_DOMAIN | |
..hiveStoragePath = path | |
..downloadPath = downloadDirectory.path; | |
var result = await atClientService | |
.onboard(atClientPreference: atClientPreference, atsign: atsign) | |
.catchError((e) => print('Error in Onboarding: $e')); | |
print('result: ' + result.toString()); | |
result ??= false; | |
/// Store the current At Sign for display | |
atClientImpl = atClientService.atClient; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment