Adpluginx Documentation
  • 👋Welcome to AdPluginx
  • Installation
    • ⚙️Install Adpluginx
    • Configure Pod For Ios
    • Configure Info.plist
    • Configure SkAdNetworks
    • Configure AppDelegate
    • Creating Native AdView
    • Init Native View to Swift Class
    • Add Onesignal to Project
  • Ad Network Indexes
    • AdConfig
    • FullScreen Ad Indexes
    • Banner Ad Indexes
    • Native Ad Indexes
  • Apple SignIn & In App Purchase
    • Enable Apple SignIn And Use
    • Skip Logic
    • InApp Purchases
    • Coin Login
Powered by GitBook
On this page

Was this helpful?

  1. Installation

Add Onesignal to Project

PreviousInit Native View to Swift ClassNextAdConfig

Last updated 2 years ago

Was this helpful?

Open Your Flutter Ios Folder in Xcode.

  • Create New Target.

  • Select Notification Extension and Name It OneSignalNotificationServiceExtension

  • Press Cancel on the Activate Scheme prompt

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

NotificationService.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)
        }
    } 
}
  • In the main app target, select Signing & Capabilities > All > + Capability, enable Push Notifications.

  • Next, enable Background Modes and check Remote Notifications.