atk*_*yla 3 objective-c ios firebase react-native firebase-cloud-messaging
我正在尝试按照此处的指南进行操作:https : //firebase.google.com/docs/cloud-messaging/ios/send-image
我去新建>目标>通知服务扩展(将此新目标嵌入到原始目标中)并粘贴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
Run Code Online (Sandbox Code Playgroud)
我现在得到Use of undeclared identifier 'FIRMessaging' in NotificationService.m.
在NotificationService.m我试图导入类似我原来的目标的AppDelegate.m地方FIRMessaging可用并且没有问题的工作:
#import "NotificationService.h"
#import <Firebase.h>
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
...
Run Code Online (Sandbox Code Playgroud)
然后我得到'Firebase.h' file not found. 我很困惑,因为它似乎在原始目标中工作,并且此通知服务扩展嵌入在该目标中。我试图搞乱Header Search Paths并Framework Search Paths没有多少运气。我究竟做错了什么?
小智 5
您只需要在现有的 podfile 中添加以下文本。
target 'NotificationImage' do
pod 'Firebase/Messaging'
end
Run Code Online (Sandbox Code Playgroud)
然后只有您才能看到要包含在项目中的文件。
| 归档时间: |
|
| 查看次数: |
4083 次 |
| 最近记录: |