繁体   English   中英

React Native 通知图像未在 IOS 上显示

[英]React Native notification image doesn't showing on IOS

我目前在通知中显示图像(带有 URL)时遇到问题。 问题仅在 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

通知服务.h

#import <UserNotifications/UserNotifications.h>

@interface NotificationService : UNNotificationServiceExtension

@end

我收到了带有 fcm_options(图片)的通知 json,但它没有出现。

信息列表

通知服务.m

通知服务.h

通知代码

通知代码之二

谢谢。

我也有同样的问题。

我遵循了 react-native-firebase 文档 但是当我图片中的“NotivicationService”是由 xcode 创建的“ImageNotification”时,它的“OS Deployment Target”与主要项目“Sitesurveillance”“OS Deployment Target”不同

在更改 ImageNotification 目标 15.2 和主项目目标 11.0 之前。 我通过更改“ImageNotification”>“Build Setting”>“OS Deployment Target”解决了它,例如“Sitesurveiilance”>“Build Setting”>“OS Deployment Target”是 11.0

这是我的项目构建设置

为了清楚起见,稍微编辑了一下

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM