I’m using the new UserNotifications framework to include image attachments in the notifications for my iOS app. I’m pulling images from different databases such as from Facebook as well as my from my own Firebase database.
I have a couple of issues.
First, if a notification image is displayed from my firebase database and the height is larger than the width and also the height exceeds the maximum image height for the notification (I’m not sure specifically what this is), the image is compressed vertically and the aspect ratio is incorrect. Note that the same images are presented correctly within my application.
Second, if a notification image is displayed from Facebook’s database and the height is larger than the width and also the height exceeds the maximum image height for the notification, the entire image will be resized to fit the maximum allowable height for the notification image, leaving white vertical bars on either side.
I would like to ensure that images that I am storing to firebase are never presented with a skewed aspect ratio. And for images that exceed the maximum allowable height, I would like to crop these images to avoid the white bars on either side.
Also worth noting, for images that I am storing to firebase, I get the same behaviour whether a photo is taken with my application or taken in the native iOS camera app and uploaded at a later time, which leads to believe that the issue is in relation to how the images are being stored to firebase as opposed to how the images are being captured and whether or not they include the appropriate metadata.
The Firebase related code I’m using to store images is simply:
if let uploadData = UIImageJPEGRepresentation(imageToStore, 0.1) {
imageStorageRef.put(uploadData, metadata: nil, completion: { (metadata, error) in
…