pub struct PushNotifications {
pub aps_environment: Option<APSEnvironment>,
pub aps_environment_macos: Option<APSEnvironment>,
pub usernotifications_filtering: Option<bool>,
}Expand description
Push Notifications
Fields§
§aps_environment: Option<APSEnvironment>The environment for push notifications.
This key specifies whether to use the development or production Apple Push Notification service (APNs) environment when registering for push notifications.
Xcode sets the value of the entitlement based on your app’s current provisioning profile. For example, if you’re using a development provisioning profile, Xcode sets the value to development. Production provisioning profile and Prerelease Versions and Beta Testers use production. These default settings can be modified. The development environment is also referred to as the sandbox environment.
Use this entitlement for both the UserNotifications and PushKit frameworks.
To add this entitlement to your app, enable the Push Notifications capability in Xcode.
§Availability
- iOS 10.0+
- tvOS 10.0+
- watchOS 3.0+
§Framework
- User Notifications
aps_environment_macos: Option<APSEnvironment>The environment for push notifications in macOS apps.
This key specifies whether to use the development or production Apple Push Notification service (APNs) environment when registering for push notifications with registerForRemoteNotifications().
Xcode sets the value of the entitlement based on your app’s current provisioning profile. For example, if you’re using a development provisioning profile, Xcode sets the value to development.
To add this entitlement to your app, enable the Push Notifications capability in Xcode.
§Availability
- macOS 10.14+
§Framework
- User Notifications
usernotifications_filtering: Option<bool>Enable receiving notifications without displaying the notification to the user.
This entitlement allows a notification service extension to receive remote notifications without displaying the notification to the user. To apply for this entitlement, see Request Notification Service Entitlement.
After you receive permission to use the entitlement, add com.apple.developer.usernotifications.filtering to the entitlements file in the Notification Service Extension target. This allows you to silence push notifications after your extension receives them.
§Silence Push Notifications
To suppress a notification’s alert, create an empty UNNotificationContent object in your extension’s didReceive(_:withContentHandler:) method, and pass it to the content handler. Don’t specify a title, subtitle, body, attachments, or sound for the content.
override func didReceive(_ request: UNNotificationRequest, withContentHandler
contentHandler: @escaping (UNNotificationContent) -> Void) {
// Determine whether you should suppress the notification.
let suppress = myShouldSuppressNotification(request: request)
if suppress {
// Don't deliver the notification to the user.
contentHandler(UNNotificationContent())
} else {
// Deliver the notification.
guard let updatedContent = request.content.mutableCopy() as?
UNMutableNotificationContent else { // This error should never
occur. fatalError("Unable to create a mutable copy of the
content") }
// Update the notification's content, such as decrypting the body, here.
contentHandler(updatedContent)
}
}§Note
To silence a remote notification, you must set the apns-push-type header field to alert when you send the notification to the APNS server. Otherwise, the system always displays the notification banner to the user.
§Availability
- iOS 13.3+
- macOS 11.0+
§Framework
- User Notifications
Trait Implementations§
Source§impl Clone for PushNotifications
impl Clone for PushNotifications
Source§fn clone(&self) -> PushNotifications
fn clone(&self) -> PushNotifications
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PushNotifications
impl Debug for PushNotifications
Source§impl Default for PushNotifications
impl Default for PushNotifications
Source§fn default() -> PushNotifications
fn default() -> PushNotifications
Source§impl<'de> Deserialize<'de> for PushNotifications
impl<'de> Deserialize<'de> for PushNotifications
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PushNotifications
impl PartialEq for PushNotifications
Source§impl Serialize for PushNotifications
impl Serialize for PushNotifications
impl Eq for PushNotifications
impl StructuralPartialEq for PushNotifications
Auto Trait Implementations§
impl Freeze for PushNotifications
impl RefUnwindSafe for PushNotifications
impl Send for PushNotifications
impl Sync for PushNotifications
impl Unpin for PushNotifications
impl UnwindSafe for PushNotifications
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.