# Push Notification Permissions

## System Permissions

#### Step 1 : **Enable Push Notifications in Xcode**

To enable push notifications for your app, follow these steps:

* Open your Xcode project.
* Navigate to **Signing & Capabilities**.
* Under **Capability**, select **Push Notifications**.

<figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2F7Xsh0X9l0E1FLzewB9kU%2Fimage.png?alt=media&#x26;token=2b5c2687-1206-4ed8-b29b-eb33abbc7f25" alt="" width="563"><figcaption></figcaption></figure>

#### Step 2: Requesting Notification Permission

To request notification permission, call the `requestPushNotificationAuthorization()` method.&#x20;

```dart
// Request push notification permission
Netmera.requestPushNotificationAuthorization().then((isGranted) {
      print("Notification auth result: $isGranted");
    });
```

{% hint style="info" %}
**Important Notes:**

In Android 13 (API 33) and higher, **runtime notification permissions** are required for push notifications. If you don't request notification permission at runtime, you can use the `requestPushNotificationAuthorization()` method from **Netmera** to request permission from the user.

* **Target API 33 or above**: Make sure your Android project is targeting **API 33** or above, as runtime permissions are required starting from Android 13.
* **User Consent**: Always inform users why you are requesting permission to send notifications, and provide them with the option to grant or deny the permission.
* **Permission Flow**: You can handle different behaviors based on whether the user has granted or denied the permission.
  {% endhint %}

#### Checking Notification Permission Status

If you need to check whether the user has granted or denied notification permissions, you can use the `checkNotificationPermission()` method. This returns an enum of the current status of the notification permission.

```dart
Netmera.checkNotificationPermission().then((status) {
      // NotificationPermissionStatus.notDetermined
      // NotificationPermissionStatus.blocked
      // NotificationPermissionStatus.denied
      // NotificationPermissionStatus.granted
 });
```

{% hint style="info" %}
**Responses**

When this method is called, it would return one of the following responses:

1. **NOTDETERMINED**\
   The user has opened the app but hasn't made a decision about notification permissions yet.
2. **BLOCKED**\
   The user has disabled notifications for the app at the system level. Even if the app tries to request permission, it will be automatically restricted by the OS.
3. **GRANTED**\
   The user has granted notification permission, and the app can send notifications.
4. **DENIED**\
   The user has denied permission or has blocked notifications through system settings.
   {% endhint %}

## Netmera Push Opt-In Status

Netmera also controls whether a device is eligible to receive push notifications:

* **`Netmera.enablePush();`** Sets the device’s status to **active (opt-in)** in the Netmera system. The device is included in the *deliverable* audience for push campaigns.
* **`Netmera.disablePush();`** Sets the device’s status to **inactive (opt-out)** in the Netmera system. Netmera will not send push notifications, even if OS-level permissions are enabled.

{% hint style="warning" %}
Push notifications are delivered only if the device has a valid push token, OS-level permission is granted, and Netmera push status is enabled.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://user.netmera.com/netmera-developer-guide/platforms/flutter/push-notifications/push-notification-permissions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
