What do you do when you don't have an entitlements file already?
What do you do when you don't have an entitlements file already?
GUIDE OF HOW TO IMPLEMENT IOS CRITICAL ALERTS [JULY 2021]
First Steps
You need to request a Critical Alert Notifications Entitlement on the Apple website.
Then you need to wait for the approval of your request from the Apple side. They will send you an email. In my case, I waited only 3 days. Some developers waited for answers for around 1-4 weeks.
WHAT DO YOU NEED TO DO AFTER REQUEST APPROVAL?
Open the Identifiers page on developer.apple.com and select the identifier of the application where you are want to enable critical alerts.

On the page that opens, click «Additional features» and tick the «Critical Alerts» box. Then click the«Save» button.

Navigate to the Profile page and click plus button to register a New Provisioning Profile.

Select the «iOS App Development» option and click the «Continue» button.

Type the name of your Provisioning Profile and click Generate button. The name can be for example your app name.

Your Provisioning Profile is ready. Click the Download button. Then double click the following file to install your Provisioning Profile.

HOW TO SELECT YOUR PROVISIONING PROFILE IN XCODE
Open your Xcode project.
Select your Target.
Select «Signing & Capabilities».
Uncheck «Automatically manage signing».
In the Provisioning Profile field select the Profile that you downloaded and installed in previous steps.

HOW TO ADD ENTITLEMENTS FILE
Guide by mobiledev99





WHAT WE NEED TO ADD TO THE CODE
Request authorization
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .badge, .sound, .criticalAlert]) { (granted, error) in}
For local notifications
Change your UNMutableNotificationContent sound to the next one:
let notificationContent = UNMutableNotificationContent()
notificationContent.sound = UNNotificationSound.defaultCritical
If you want to use your custom sound, you need to replace the code with this one:
let notificationContent = UNMutableNotificationContent()
notificationContent.sound = UNNotificationSound.criticalSoundNamed(UNNotificationSoundName(rawValue:"YourCustomSound.mp3"))
For push notifications(From Tapcode tutorial)
{
"aps":{
"alert": "This is a Critical Alert!",
"badge": 1,
"sound": {
"critical": 1,
"name": "your_custom_sound.aiff",
"volume": 1.0
}
}
}
There are several sources that can help you implement critical alerts for your iOS app. I found two that were very helpful:
https://www.tapcode.co/2018/10/17/how-to-implement-critical-alerts-in-ios-12/
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 arrived at the following steps that can be used as a guide for dealing with this dilemma. When you get to the part of the articles that tackle updating the entitlements file please proceed as follows:
Mission accomplished!
Terry Chaisson