简体   繁体   中英

React Native notification image doesn't showing on IOS

I have currently a problem to display image in notification (with an url). The problem is only on iOS, it works on Android.

I'm using React Native Firebase:

It works on Android but not in iOS.

I have created the Notification Service and i have followed the react-native-firebase documentation and the image still doesn't appear.

NotificationService.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

I received the notification json with the fcm_options (image) but it doesn't appear.

Info.plist

NotificationService.m

NotificationService.h

Notification Code

Notification Code Bis

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"

Before change ImageNotification target 15.2 and main project target 11.0. I solved it by change "ImageNotification" > "Build Setting" > "OS Deployment Target" like the "Sitesurveiilance" > "Build Setting" > "OS Deployment Target" is 11.0

this is my project build setting

Edited a bit for clarity

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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