The following code should work to prevent app deletion provided that your app is properly authorized in FamilyControls:
let store = ManagedSettingsStore()
store.application.denyAppRemoval = true
Please ensure that the process using the ManagedSettings API is entitled with the FamilyControls capability and that the app is authorized via FamilyControls. If the problem persists, please file a report via Feedback Assistant and attach a sysdiagnose.
I want to deny deleting of my app.
Please note that application.denyAppRemoval
isn't guaranteed to prevent your app from being deleted with .individual
authorization, since .individual
authorizations can be revoked at any time via Settings. If you'd like for your app to not be deletable on a child device, consider using a .child
enrollment in FamilyControls. Please refer to the FamilyControls documentation for more information.