When returning to the sharing panel from the sharing details page, you can set resultCode to a specific ShareAbilityResultCode value to instruct the sharing panel to perform a proper operation. The options are as follows:
ERROR: Returns to the sharing panel and displays an error message.
BACK: Returns to the sharing panel properly.
CLOSE: Closes the sharing panel.
Import required modules.
import { ShareExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
import { systemShare } from '@kit.ShareKit'; Configure the target app to call the terminateSelfWithResult API to set resultCode to systemShare.ShareAbilityResultCode.CLOSE to close the sharing panel.
export default class TestShareAbility extends ShareExtensionAbility {
async onSessionCreate(want: Want, session: UIExtensionContentSession) {
session.terminateSelfWithResult({
resultCode: systemShare.ShareAbilityResultCode.CLOSE
});
}
}