> For the complete documentation index, see [llms.txt](https://rehanabbas.gitbook.io/adpluginx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rehanabbas.gitbook.io/adpluginx/installation/add-onesignal-to-project.md).

# Add Onesignal to Project

Open Your Flutter Ios Folder in Xcode.

* Create New Target.
* Select Notification Extension and Name It OneSignalNotificationServiceExtension

<figure><img src="/files/Y4NjAMMxpvsTvEiQUshP" alt=""><figcaption></figcaption></figure>

*

```
<figure><img src="https://files.readme.io/c172285-Screen_Shot_2021-08-17_at_6.16.50_PM.png" alt=""><figcaption></figcaption></figure>
```

* Press `Cancel` on the `Activate Scheme` prompt

<figure><img src="https://files.readme.io/cdfe6de-2.png" alt=""><figcaption></figcaption></figure>

* In your project, in the `OneSignalNotificationServiceExtension/` folder, open `NotificationService.m` and replace the whole file contents with:

{% code title="NotificationService.Swift" lineNumbers="true" %}

```swift
import UserNotifications

import OneSignal

class NotificationService: UNNotificationServiceExtension {
    
    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?
    
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.receivedRequest = request
        self.contentHandler = contentHandler
        self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        if let bestAttemptContent = bestAttemptContent {   
            OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
        }
    }
    
    override func serviceExtensionTimeWillExpire() {
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    } 
}
```

{% endcode %}

* In the main app target, select **Signing & Capabilities** > **All** > **+ Capability**, enable **Push Notifications**.
*

```
<figure><img src="/files/Nb6VD5ZHkxKoRnvVlubI" alt=""><figcaption></figcaption></figure>
```

* Next, enable **Background Modes** and check **Remote Notifications**.
*

```
<figure><img src="/files/QEMiO8TpceEWtCqA2pYm" alt=""><figcaption></figcaption></figure>
```
