PushNotifications

Struct PushNotifications 

Source
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

Source§

fn clone(&self) -> PushNotifications

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PushNotifications

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PushNotifications

Source§

fn default() -> PushNotifications

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PushNotifications

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PushNotifications

Source§

fn eq(&self, other: &PushNotifications) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PushNotifications

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for PushNotifications

Source§

impl StructuralPartialEq for PushNotifications

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,