2024-09-24 01:01:32
tinycoder.pika.page
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.
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.