Critical Alerts

  1. SDK Version: 42 managed
  2. Platforms(Android/iOS/web/all): ios

Hello, i have requested critical alerts by apple and this is now approved. Im looking how to integrate this feature but there are no docs . Normal notifications are handled as expected.
Do u have any idea to integrate critical alerts?

Yep, for local notifications you can set the sound to defaultCritical: Notifications - Expo Documentation

For remote notifications, you’ll need to use APNs directly, as opposed to Expo’s push service.

ok, i have created a scheduled Notification:

await Notifications.scheduleNotificationAsync({
      content: {
        title: " 📬",
        sound: 'defaultCritical', // Provide ONLY the base filename
      },
      trigger: {
        seconds: 5,
        channelId: 'default',
      },
      });

This doesnt work for me.
Do i need request extra permissions for critical alerts?

Yes, it looks like you need to do that. See the requestPermissionsAsync documentation, in particular the Arguments.

See also: Fetching information about notifications-related permissions

1 Like

It also looks like you’re in managed- since this feature requires the special entitlement from Apple, it will not work in Expo Go. You’ll need to test in a standalone app

1 Like

Ok. Maybe thats the mistake. I will create a standalone build and test ist again.

After testing standalone app, the alerts only receive as normal notifications.

Here is the Notification Permission request:

const test = await Notifications.requestPermissionsAsync({
          android: {},
          ios: {
            allowAlert: true,
            allowBadge: true,
            allowSound: true,
            allowAnnouncements: true,
            allowCriticalAlerts: true
          }
    })
    console.log(test)

and here the response

"ios": Object {
    "alertStyle": 2,
    "allowsAlert": true,
    "allowsAnnouncements": null,
    "allowsBadge": true,
    "allowsCriticalAlerts": null,
    "allowsDisplayInCarPlay": null,
    "allowsDisplayInNotificationCenter": true,
    "allowsDisplayOnLockScreen": true,
    "allowsPreviews": 1,
    "allowsSound": true,
    "providesAppNotificationSettings": false,
    "status": 2,
  },
  "status": "granted",
}

as u can see, the criticalalerts permission is null, not true. I think thats the last thing to handle. How set it to true?

Just a wild guess, but what happens if you do this:

const test = await Notifications.requestPermissionsAsync({
  allowAlert: true,
  allowBadge: true,
  allowSound: true,
  allowAnnouncements: true,
  allowCriticalAlerts: true
})
console.log(test)

The property „allowAlerts“ of Type NotificationPermissionRequest doesnt exist. Ist needs the ios key as parent.

1 Like

Ok, i tried another solution to figure it out.
in app.json i created a new entry in ios key:

"entitlements": {
    "com.apple.developer.usernotifications.critical-alerts" : 1
 }

The upload through transporter results in the following error:

ERROR ITMS-90164: “Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. According to the provisioning profile, the bundle contains a key value that is not allowed: ‘1’ for the key ‘com.apple.developer.usernotifications.critical-alerts’ in ‘Payload/myapp.app/myapp’.”

Why its not allowed? my provisioning profile by apple shows that critical alerts are enabled??

And you’re sure the correct provisioning profile is being used when building the app? Maybe extract it from the IPA and double check. I’ve never done that before, but this looks like it should work.

Yes, the extracted embedded.mobileprovision file contains the same as the given i found by apple. But the content is not readable. It looks only similar to both files.

update:
after reviewing again as .txt i see the key/value pair

<key>com.apple.developer.usernotifications.critical-alerts</key>
<true/>

so its definetively set to true in expos & apples mobileprovision.
Ok. why its not prompting in app?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.