Does creating an INImage from a URL work?

Viewed 124

I would like to use INImage.init(url:) for displaying a user profile image in a notification.

This initializer is documented with:

A URL that specifies an image file on a remote server. The image file can be in any format supported by the system, but it is recommended that you use PNG images.

However, as far as I can tell, this simply does not work – the image in the URL is never displayed. I have seen many other posts claiming that it does not work for them either.

Am I missing something or is this simply a bug?

I am working around it right now with the following extension:

extension INImage {
    convenience init?(contentsOf url: URL) {
        if let data = try? Data(contentsOf: url) {
            self.init(imageData: data)
        } else {
            return nil
        }
    }
}

This doesn't seem great, because the image isn't cached and has to be downloaded every time a notification comes in, which seems really bad.

0 Answers
Related