我目前在通知中显示图像(带有网址)时遇到问题。 该问题仅在 iOS 上出现,在 Android 上可以。
我正在使用 React Native Firebase :
它适用于 Android,但不适用于 iOS。
我已经创建了通知服务,并且遵循了react-native-firebase文档,但图像仍然没有出现。
通知服务.m
#import "NotificationService.h"
#import "FirebaseMessaging.h"
@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];
[[FIRMessaging extensionHelper]
populateNotificationContent:self.bestAttemptContent
withContentHandler:contentHandler];
}
- (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
NotificationService.h
#import <UserNotifications/UserNotifications.h>
@interface NotificationService : UNNotificationServiceExtension
@end
我收到了带有 fcm_options (图像)的通知 json,但它没有出现。
谢谢你。
就我而言,在将 iOS 部署目标从 12.0 更改为 13.4 以进行通知扩展后,它开始工作。