Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

How to add Notification Service Extension for Firebase?

$
0
0

I am trying to follow the guide here: https://firebase.google.com/docs/cloud-messaging/ios/send-image

I went to New > Target > Notification Service Extension (embedded this new target into the original target) and pasted in NotificationService.m:

@interface NotificationService ()@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;@end@implementation NotificationService- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {    self.contentHandler = contentHandler;    self.bestAttemptContent = [request.content mutableCopy];    // Modify the notification content here...    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title];    // Call FIRMessaging extension helper API.    [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent                                             withContentHandler:contentHandler];    self.contentHandler(self.bestAttemptContent);}- (void)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.    self.contentHandler(self.bestAttemptContent);}@end

I am now getting Use of undeclared identifier 'FIRMessaging' in NotificationService.m.

In NotificationService.m I tried to import similarly to my original target's AppDelegate.m where FIRMessaging is available and working with no issues:

#import "NotificationService.h"#import <Firebase.h>#import "RNFirebaseNotifications.h"#import "RNFirebaseMessaging.h"...

Then I get 'Firebase.h' file not found. I am confused because it seems to work in the original target, and this notification service extension is embedded in that target. I have tried messing with Header Search Paths and Framework Search Paths without much luck. What am I doing wrong?


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>