Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create an AtClient
/// 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