# iOS SDK - Push Notification Management Module (/limited-release/wlw/ios-sdk/push-notifications)



Use the endpoints of this module to enable delivery of alert messages - such as available app updates, new offers, upcoming deadlines, new store locations, etc. - from the mobile app to the device, even when the app is not active.

> **Note:** **Note:** When implementing push notifications, ensure the app listens for iOS events related to changes to the user's push notification settings. If a user disables notifications for the app, invoke [`Unregister`](#unregisterdeviceforpushnotifications). If the user re-enables notifications, invoke [`Register`](#registerdeviceforpushnotifications).
> Also, when a user re-links a previously unlinked device or links a new device to an existing account, the app must prompt the user to enable push notifications again.

## Initialize Push Notification Management Facade [#initialize-push-notification-management-facade]

Prior to invoking any push notification management module endpoints:

1. Create a new request object for the relevant coordinator.

2. Implement the delegate for the coordinator to handle responses.

<div className="pl-[1.625rem]" />

```text lineNumbers
PDPushNotificationCoordinator *coordinator = [[PDPushNotificationCoordinator alloc] init];
  self.PushNotificationCoordinator = coordinator;
  [coordinator release];
```

## isDeviceRegisteredForPushNotifications [#isdeviceregisteredforpushnotifications]

Checks whether the wallet owner has agreed to receive device alerts from the Paydiant platform.

| Element          | Value                                                                                                                                                                                                                                                                                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Signature | `-(void)isDeviceRegisteredForPushNotifications;`                                                                                                                                                                                                                                                                                                      |
| Success          | `void (^isDeviceRegisteredForPushNotificationsCompletionBlock(BOOL isRegistered);`<br /><br />`isRegistered` - Indicates whether Paydiant has obtained a device token signaling user consent for push notifications. Valid values are:<br />`Yes` - Paydiant has a valid device token.<br />`No` - Paydiant has no device token. Invoke registration. |
| Failure          | `void (^isDeviceRegisteredForPushNotificationsFailureBlock)(`[`PDPaydiantError`](/limited-release/wlw/ios-sdk/objects-error/)` *pushNotificationManagementError);`                                                                                                                                                                                    |

Configure user error messages for this call with the key `kUserErrorisDeviceRegisteredForPushNotificationsDomain`.

| Error | Description                                         |
| ----- | --------------------------------------------------- |
| `403` | The user must be logged in to make this call.       |
| `500` | An unknown error occurred internally in the server. |

## registerDeviceForPushNotifications [#registerdeviceforpushnotifications]

Captures and store the device token generated when the user consents to receive push notifications from Paydiant.

| Element          | Value                                                                                                                                                                                                          |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Signature | `-(void)registerDeviceForPushNotifications:(NSString *)deviceToken;`<br /><br />`deviceToken` - The value of the iOS-generated token signaling the user's consent to receive push notifications from Paydiant. |
| Success          | `void (^RegisterDeviceForPushNotificationsCompletionBlock);`                                                                                                                                                   |
| Failure          | `void (^RegisterDeviceForPushNotificationsFailureBlock)(`[`PDPaydiantError`](/limited-release/wlw/ios-sdk/objects-error/)` *pushNotificationManagementError);`                                                 |

Configure user error messages for this call with the key `kUserErrorRegisterDeviceForPushNotificationsDomain`.

| Error | Description                                                            |
| ----- | ---------------------------------------------------------------------- |
| `400` | Could not register the device due to invalid arguments in the request. |
| `403` | The user must be logged in to make this call.                          |
| `500` | An unknown error occurred internally in the server.                    |

## unregisterDeviceForPushNotifications [#unregisterdeviceforpushnotifications]

Removes the device token that identifies the device as registered to receive push notifications from Paydiant.

| Element          | Value                                                                                                                                                            |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Signature | `-(void)unregisterDeviceForPushNotifications:();`                                                                                                                |
| Success          | `void (^UnregisterDeviceForPushNotificationsCompletionBlock)();`                                                                                                 |
| Failure          | `void (^UnregisterDeviceForPushNotificationsFailureBlock)(`[`PDPaydiantError`](/limited-release/wlw/ios-sdk/objects-error/)` *pushNotificationManagementError);` |

Configure user error messages for this call with the key `kUserErrorUnregisterDeviceForPushNotificationsDomain`.

| Error | Description                                                   |
| ----- | ------------------------------------------------------------- |
| `400` | Could not unregister the device because it is not registered. |
| `403` | The user must be logged in to make this call.                 |
| `500` | An unknown error occurred internally in the server.           |
