getShareableUrlForToken method
Builds the share link of an activity.
Parameters
shareToken: The Activity.shareToken of the activity.onComplete: Called with GemError.success and the link: ActivityStoreConfig.shareWebBaseUrl followed by the token (the backend preview function when the base is empty), or an empty string when the token is empty.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? getShareableUrlForToken(
String shareToken, {
void Function(GemError error, String url)? onComplete,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
progressListener.registerOnCompleteWithData((
int err,
String hint,
Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progressListener.id);
if (err == 0) {
onComplete?.call(GemErrorExtension.fromCode(err), json['result']);
} else {
onComplete?.call(GemErrorExtension.fromCode(err), '');
}
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'getShareableUrlForToken',
args: <String, dynamic>{
'shareToken': shareToken,
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode, '');
return null;
}
return progressListener;
}