Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Notification images without proper path extensions #6590

Closed
akivab opened this issue Sep 29, 2020 · 0 comments
Closed

Allow Notification images without proper path extensions #6590

akivab opened this issue Sep 29, 2020 · 0 comments

Comments

@akivab
Copy link
Contributor

akivab commented Sep 29, 2020

Environment

  • Xcode version: Version 12.0.1 (12A7300)
  • Firebase SDK version: 6.33.0
  • Firebase Component: Messaging
  • Component version: 6.33.0
  • Installation method: CocoaPods

Problem

Firebase Messaging does not seem to allow for image URLs without an extension that matches MIME type, despite the fact that we may be able to produce the right extension from the MIME type.

In the function

- (void)loadAttachmentForURL:(NSURL *)attachmentURL
           completionHandler:(void (^)(UNNotificationAttachment *))completionHandler {

We create the extension for the local download using

        NSString *suggestedPathExtension = [response.suggestedFilename pathExtension];

Which raises issues later in the function, i.e.

            FIRMessagingLoggerError(
                                    kFIRMessagingServiceExtensionLocalFileNotCreated,
                                    @"Failed to move the image file to local location: %@, error: %@\n", localURL,
                                    error);

Steps to reproduce:

What happened? How can we make the problem occur?

Create a notification with a URL that points to an image resource without the proper extension (e.g. a UUID)

Relevant Code:

Fixed the issue by changing the logic to

        NSString *suggestedPathExtension = [response.suggestedFilename pathExtension];
        NSString *mimeTypePathExtension = [response.MIMEType stringByReplacingOccurrencesOfString:@"image/" withString:@""];
        NSString *pathExtension = ((suggestedPathExtension.length > 0) ? suggestedPathExtension : mimeTypePathExtension);
        NSString *fileExtension = [NSString stringWithFormat:@".%@", pathExtension];
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants