Closed fabyeah closed 3 years ago
I guess the NotificationService.swift
is the correct file, just swift instead of Obj-C. This is my file:
import UserNotifications
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)
}
}
}
How do I make the adjustments in swift? I can't import NotifeeExtensionHelper
as Xcode says "No such module".
Also, I guess the rnfirebase.io guide on iOS setup has to be followed, as well, without changes, right?
hey, sorry you've found this difficult. We have videos coming soon on the docs to help with demonstrating how to do this.
When you add the new target, in this case the notification service extension, ensure the language is Objective-C.
Thanks, that did the trick! 👍🎉
I'm trying to follow the guide here: https://notifee.app/react-native/docs/ios/remote-notification-support
But I'm stuck at the "Use the extension helper" part. I don't have much experience with Xcode and don't know how to do this: "From the navigator select your extension". In my Navigator I have a folder
NotifeeNotificationService
, but that only containsNotificationService.swift
andInfo.plist
. I cannot find this line of code anywhere in my project folder:#import "NotificationService.h"
after which i'm supposed to add code.What am I missing?