You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I was following the migration file, and I think one step is missing: we should update the OneSignalNotificationServiceExtension file with this code.
import UserNotifications
import OneSignalExtension
classNotificationService:UNNotificationServiceExtension{varcontentHandler:((UNNotificationContent)->Void)?varreceivedRequest:UNNotificationRequest!varbestAttemptContent:UNMutableNotificationContent?overridefunc didReceive(_ request:UNNotificationRequest, withContentHandler contentHandler:@escaping(UNNotificationContent)->Void){self.receivedRequest = request
self.contentHandler = contentHandler
self.bestAttemptContent =(request.content.mutableCopy()as?UNMutableNotificationContent)iflet bestAttemptContent = bestAttemptContent {
/* DEBUGGING: Uncomment the 2 lines below to check this extension is executing
Note, this extension only runs when mutable-content is set
Setting an attachment or action buttons automatically adds this */
// print("Running NotificationServiceExtension")
// bestAttemptContent.body = "[Modified] " + bestAttemptContent.body
OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler:self.contentHandler)}}overridefunc 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.
iflet contentHandler = contentHandler,let bestAttemptContent = bestAttemptContent {OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with:self.bestAttemptContent)contentHandler(bestAttemptContent)}}}
Once the old version imported OneSignal, it is now required to import OneSignalExtension.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
What's on your mind?
Hey, I was following the migration file, and I think one step is missing: we should update the
OneSignalNotificationServiceExtension
file with this code.Once the old version imported
OneSignal,
it is now required to importOneSignalExtension
.Code of Conduct
The text was updated successfully, but these errors were encountered: