How to Implement Critical Alerts for Your App

(when you don’t have an entitlements file)

There are several sources that can help you implement critical alerts for your app. The two below are very helpful:

https://www.tapcode.co/2018/10/17/how-to-implement-critical-alerts-in-ios-12/

https://medium.com/@shashidharyamsani/implementing-ios-critical-alerts-7d82b4bb5026#:~:text=iOS%2012%20has%20the%20critical,allowed%20to%20send%20critical%20alerts.

Both describe what is necessary to request approval from Apple and how to update your project to include critical alerts notifications — with one exception. The articles explain how to update your entitlements file to add the critical alerts key. But what do you do when your app currently does not have an entitlements file? After a bit of research, I prepared the following steps as a guide for dealing with this dilemma.

When you get to the part of the articles that address updating the entitlements file please proceed as follows:

1. Under the Capabilities tab, click on + (plus) to add a capability (I picked Keychain Sharing). This will cause Xcode to generate a <project-name>.entitlements file (major hurdle overcome).

2. Click on that file in the Project Navigator to open it. You will see the key for the capability that you have chosen (Keychain Sharing) if the disclosure triangle next to Entitlements File is open. If the disclosure triangle is not open, please click it to open it.

3. Click on + (plus) next to Entitlements File to add an entitlement. A dropdown with selections will appear but you will have to type the key for critical alerts notifications in order to enter it manually.

4. Enter the key for critical alerts notifications that is in the articles:

com.apple.developer.usernotifications.critical-alerts

5. Change the type to Boolean and select YES as the value.

6. Click on — (dash) next to the capability that you used to create the entitlements file in step 1 (Keychain Sharing) to delete it. You now have an entitlements file with the critical alerts key that you need.

7. Build and run your app and you should see the prompt that asks the user to allow critical alerts.

Mission accomplished!

Terry Chaisson

ChecktheBack! App on App Store and Google Play, Website: MobileDev99.com, Email: terry@mobiledev99.com

This article first appeared on the MobileDev99 blog at https://www.mobiledev99.com/MD99Blog/md99blog.html.