[英]React Native notification image doesn't showing on IOS
I have currently a problem to display image in notification (with an url).我目前在通知中显示图像(带有 URL)时遇到问题。 The problem is only on iOS, it works on Android.
问题仅在 iOS 上,它适用于 Android。
I'm using React Native Firebase:我正在使用 React Native Firebase:
It works on Android but not in iOS.它适用于 Android 但不适用于 iOS。
I have created the Notification Service and i have followed the react-native-firebase documentation and the image still doesn't appear.我已经创建了通知服务并且我已经按照 react-native-firebase 文档进行操作,但图像仍然没有出现。
NotificationService.m通知服务.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通知服务.h
#import <UserNotifications/UserNotifications.h>
@interface NotificationService : UNNotificationServiceExtension
@end
I received the notification json with the fcm_options (image) but it doesn't appear.我收到了带有 fcm_options(图片)的通知 json,但它没有出现。
Thanks you.谢谢。
I have the same problem.我也有同样的问题。
I have followed the react-native-firebase documentation But when "NotivicationService" in my picture is "ImageNotification" created by xcode, It's "OS Deployment Target" is different the main project "Sitesurveillance" "OS Deployment Target"我遵循了 react-native-firebase 文档 但是当我图片中的“NotivicationService”是由 xcode 创建的“ImageNotification”时,它的“OS Deployment Target”与主要项目“Sitesurveillance”“OS Deployment Target”不同
Before change ImageNotification target 15.2 and main project target 11.0.在更改 ImageNotification 目标 15.2 和主项目目标 11.0 之前。 I solved it by change "ImageNotification" > "Build Setting" > "OS Deployment Target" like the "Sitesurveiilance" > "Build Setting" > "OS Deployment Target" is 11.0
我通过更改“ImageNotification”>“Build Setting”>“OS Deployment Target”解决了它,例如“Sitesurveiilance”>“Build Setting”>“OS Deployment Target”是 11.0
this is my project build setting这是我的项目构建设置
Edited a bit for clarity为了清楚起见,稍微编辑了一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.