saveSharedActivity method
Keeps a shared activity the user opened from a link, or refreshes the kept copy.
Shared activities are kept per recipient, locally only, and never synced.
Parameters
recipientUserID: The user who keeps the activity; must not be empty.activity: The activity, as resolved by fetchSharedActivityByToken; its Activity.shareToken identifies it and must be set. The StoredActivityFile.localPath of its files are the absolute paths of the files downloaded so far.onComplete: Called with GemError.success, or another GemError when the activity could not be kept.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? saveSharedActivity({
required String recipientUserID,
required Activity activity,
void Function(GemError error)? 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);
onComplete?.call(GemErrorExtension.fromCode(err));
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'saveSharedActivity',
args: <String, dynamic>{
'recipientUserID': recipientUserID,
'activity': activity.toJson(),
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}