# Managing Notifications

## Push Notifications

You can enable Luciq to send your users push notifications each time you send them a new message.

### Uploading Your Push Certificate

Follow the steps below to upload your push certificate to your Luciq dashboard.

1. Follow [this tutorial to generate a push certificate and export it to a `.pem` file](https://www.luciq.ai/blog/how-to-generate-a-push-certificate-and-export-it-to-a-pem-file/).
2. Go to the **Push Notifications** page on your Luciq dashboard and upload your `.pem` file.
3. Select whether the certificate you're uploading is for development or production, and enter the pass phrase if you set one.

### Handling Luciq Notifications

In `application:didRegisterForRemoteNotificationsWithDeviceToken:`, pass the token you get to Luciq.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Replies.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [LCQReplies didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

When you receive a notification, check if it's a Luciq notification, then pass it to Luciq if necessary.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    let isLuciqNotification = Replies.didReceiveRemoteNotification(userInfo)
}
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    BOOL isLuciqNotification = [LCQReplies didReceiveRemoteNotification:userInfo];
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

And finally, handle when your application has been launched from a Luciq notification. Add the following to `application:didFinishLaunchingWithOptions:`.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
if let notification = launchOptions?[.remoteNotification] as? [String: AnyObject] {
    let isLuciqNotification = Replies.didReceiveRemoteNotification(notification)
}
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
NSDictionary *notificationDictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

BOOL isLuciqNotification = [LCQReplies didReceiveRemoteNotification:notificationDictionary];
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Disabling Push Notifications

Push notifications are enabled by default if you upload a push certificate to your Luciq dashboard. To disable them, use the following method.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
Replies.pushNotificationsEnabled = false
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
[LCQReplies setPushNotificationsEnabled:NO];
```

{% endcode %}
{% endtab %}
{% endtabs %}

## In-App Notifications

By default, a notification will be shown on top of your app's UI when a new message is received.

{% hint style="info" %}

#### Email Notifications

If your user doesn't view the new message within 10 minutes, they will be sent an email notification as well.
{% endhint %}

### Disabling In-App Notifications

Use the following method to disable notifications that appear in-app.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
Replies.inAppNotificationsEnabled = false
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
LCQReplies.inAppNotificationsEnabled = NO;
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Getting Unread Messages Count

You can use the following method to get the number of messages a user has yet to read.

{% tabs %}
{% tab title="Swift" %}
{% code overflow="wrap" %}

```swift
let messageCount = Replies.unreadRepliesCount
```

{% endcode %}
{% endtab %}

{% tab title="Objective-C" %}
{% code overflow="wrap" %}

```objectivec
NSUInteger messageCount = LCQReplies.unreadRepliesCount;
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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://docs.luciq.ai/ios/setup-luciq-for-ios/setup-in-app-replies/managing-notifications.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.
