Preventing app removal on iOS
2024-9-28 21:30:25 Author: govuln.com(查看原文) 阅读量:10 收藏

An image with caption: You can still remove the app from Home Screen, but it is not uninstalled.
You can still remove the app from Home Screen, but it is not uninstalled.

These days, I am developing an alarm app called ‘SuperAlarm’.

To ensure a user is awake, SuperAlarm can be turned off only after a user completes a mission(e.g., taking a picture of toothbrush, solving puzzles, keeping eyes open). The most frequent complaint from users was that they could easily turn off alarms by simply removing the app.

This problem does not exist on SuperAlarm for Android, since users cannot exit from the app to the home screen while the alarm is going off. However, this is not possible on iOS. So how can I solve this problem on iOS?

After some research, I found that some habit-related apps prevented themselves from being removed, on iPhones. The key is using Screen Time API of iOS.
After getting approval from the user, the developer can set a flag to deny app removal.

ManagedSettingsStore().application.denyAppRemoval = true

Yes, this single line of code is all you need.

This way, I prevented users from removing the app while the alarm is ringing.
After users complete the missions, I disable this flag to allow removing the app.

Note 1
To use this API, you should be approved for Family Controls & Personal Device Usage Entitlement by Apple. You can submit the form here.

Note 2
This feature must be opt-in. To enable the flag, you should explicitly get approval from the user.


文章来源: https://govuln.com/news/url/9kkQ
如有侵权请联系:admin#unsafe.sh