Does creating an INImage from a URL work?

Published

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.

Source: Ios Questions

Published
Categorised as ios, sirikit, swift Tagged , ,

Answers

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq