It still does not support Rich Notifications (Notifications with Image) on iOS, Anybody has workaround for this??? If not this would be a feature request.
@kaumudpa
The issue at https://github.com/flutter/flutter/issues/35866 has been closed and moved here. Future collaboration on this issue will be done here.
Do we have any updates on this one?
@kaumudpa we are currently working on getting FCM on iOS stable. Adding support for rich notifications is on our roadmap, thanks for pinging this issue.
Any update or custom solution on this?
any service class or any fix available via https://docs.mobile.sailthru.com/docs/ios-extensions-framework CarnivalNotificationServiceExtension?
@kroikie any early access solutions available?
@kroikie @iapicca
I'm curious how the plugin handles images on the Android side.
Can this PR https://github.com/FirebaseExtended/flutterfire/pull/2016 somehow help this issue?
Still waiting for a resolution to this one!
@p30arena this is to deal with ios Rich notification extension, flutter SDK should call ios-extensions-framework @tobiasjunsten any work arround is possible ?
Open Xcode, File -> New -> Target... -> Add Notification Service Extension (Product Name: NotificationService, lang: Objective-C)
Open file NotificationService.m, change content flow: https://docs.mobile.sailthru.com/docs/ios-rich-push:
#import "NotificationService.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@property (nonatomic, strong) NSURLSessionDownloadTask *downloadTask;
@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 sailthruRichNotificationAttachments:self.bestAttemptContent withResponse:^(UNMutableNotificationContent * _Nullable content) {
self.bestAttemptContent = content;
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.downloadTask cancel];
self.contentHandler(self.bestAttemptContent);
}
- (void)sailthruRichNotificationAttachments:(UNMutableNotificationContent *)originalContent withResponse:(nullable void(^)(UNMutableNotificationContent *__nullable modifiedContent))block {
// For Image or Video in-app messages, we will send the media URL in the
// _st payload
NSString *imageURL = originalContent.userInfo[@"fcm_options"][@"image"];
NSString *videoURL = originalContent.userInfo[@"fcm_options"][@"video"];
NSURL *attachmentURL = nil;
if (videoURL && ![videoURL isKindOfClass:[NSNull class]]) { //Prioritize videos over image
attachmentURL = [NSURL URLWithString:videoURL];
}
else if (imageURL && ![imageURL isKindOfClass:[NSNull class]]) {
attachmentURL = [NSURL URLWithString:imageURL];
}
else {
block(originalContent); //Nothing to add to the push, return early.
return;
}
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
self.downloadTask = [session downloadTaskWithURL:attachmentURL completionHandler:^(NSURL *fileLocation, NSURLResponse *response, NSError *error) {
if (error != nil) {
block(originalContent); //Nothing to add to the push, return early.
return;
}
else {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileSuffix = attachmentURL.lastPathComponent;
NSURL *typedAttachmentURL = [NSURL fileURLWithPath:[(NSString *_Nonnull)fileLocation.path stringByAppendingString:fileSuffix]];
[fileManager moveItemAtURL:fileLocation toURL:typedAttachmentURL error:&error];
NSError *attachError = nil;
UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:@"" URL:typedAttachmentURL options:nil error:&attachError];
if (attachment == nil) {
block(originalContent); //Nothing to add to the push, return early.
return;
}
UNMutableNotificationContent *modifiedContent = originalContent.mutableCopy;
[modifiedContent setAttachments:[NSArray arrayWithObject:attachment]];
block(modifiedContent);
}
}];
[self.downloadTask resume];
}
@end
note: change this flow your notification model:
My notification I received is:
{fcm_options: {image: https://file.hstatic.net/1000187248/file/noi_bat_b65bf35c4bbf49f19315f758a4a15e02.jpg}, gcm.message_id: 1591237257298321, google.c.a.e: 1, aps: {alert: {title: test, body: test notification image}, mutable-content: 1.0}}
=> so:
NSString *imageURL = originalContent.userInfo[@"fcm_options"][@"image"];
NSString *videoURL = originalContent.userInfo[@"fcm_options"][@"video"];

=> Done

any news about this issue ?
Any news about this :) ?
doing a photography based app and it would be great to have this functionality for iOS
Hey all 馃憢
As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues. Specifically see the Notifications with images documentation: https://firebase.flutter.dev/docs/messaging/apple-integration/#advanced-optional-allowing-notification-images
If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.
Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.
Thanks everyone 馃
Most helpful comment
Open Xcode, File -> New -> Target... -> Add Notification Service Extension (Product Name: NotificationService, lang: Objective-C)
Open file NotificationService.m, change content flow: https://docs.mobile.sailthru.com/docs/ios-rich-push:
note: change this flow your notification model:
My notification I received is:
{fcm_options: {image: https://file.hstatic.net/1000187248/file/noi_bat_b65bf35c4bbf49f19315f758a4a15e02.jpg}, gcm.message_id: 1591237257298321, google.c.a.e: 1, aps: {alert: {title: test, body: test notification image}, mutable-content: 1.0}}=> so:
=> Done