Skip to content

Commit

Permalink
use airship's UANotificationServiceExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Dec 8, 2023
1 parent 4335e95 commit 19dd7b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
27 changes: 2 additions & 25 deletions ios/CustomNotificationServiceExtension/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,8 @@
// Created by Andrew Rosiclair on 12/8/23.
//

import UserNotifications
import AirshipServiceExtension

class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"

contentHandler(bestAttemptContent)
}
}

override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
class NotificationService: UANotificationServiceExtension {

}
4 changes: 4 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ target 'NewExpensify' do
end
end
end

target 'CustomNotificationServiceExtension' do
pod 'AirshipServiceExtension'
end
6 changes: 5 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PODS:
- Airship (= 16.12.1)
- Airship/MessageCenter (= 16.12.1)
- Airship/PreferenceCenter (= 16.12.1)
- AirshipServiceExtension (16.12.5)
- AppAuth (1.6.2):
- AppAuth/Core (= 1.6.2)
- AppAuth/ExternalUserAgent (= 1.6.2)
Expand Down Expand Up @@ -828,6 +829,7 @@ PODS:
- Yoga (~> 1.14)

DEPENDENCIES:
- AirshipServiceExtension
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- BVLinearGradient (from `../node_modules/react-native-linear-gradient`)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
Expand Down Expand Up @@ -942,6 +944,7 @@ SPEC REPOS:
trunk:
- Airship
- AirshipFrameworkProxy
- AirshipServiceExtension
- AppAuth
- CocoaAsyncSocket
- Firebase
Expand Down Expand Up @@ -1162,6 +1165,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Airship: 2f4510b497a8200780752a5e0304a9072bfffb6d
AirshipFrameworkProxy: ea1b6c665c798637b93c465b5e505be3011f1d9d
AirshipServiceExtension: 89c6e25a69f3458d9dbd581c700cffb196b61930
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: 421743791a59d259aec53f4c58793aad031da2ca
Expand Down Expand Up @@ -1291,6 +1295,6 @@ SPEC CHECKSUMS:
Yoga: 3efc43e0d48686ce2e8c60f99d4e6bd349aff981
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: ff769666b7221c15936ebc5576a8c8e467dc6879
PODFILE CHECKSUM: c44319b85c142746fd25749dc13f06ce81273f22

COCOAPODS: 1.12.1

0 comments on commit 19dd7b9

Please sign in to comment.