Alright Im building a message extension app with a uicollectionview with header and footer. After several tries I learned why I wasn't able to open a url from the message controller using normal syntax - because its an extension it should use:
let url: URL = URL(string: "http://www.google.com")!
self.extensionContext?.open(url, completionHandler: { (success: Bool) in
print("hi")
})
And this COMPILES but does not work in the MessageViewController file. I don't know why, but then in my
class FooterCollectionReusableView: UICollectionReusableView {
this does not compile even. I get the error
How can I open a url from my footer in my message extension? Is this possible?
It looks like you're calling extensionContext on your
FooterCollectionReusableView
.extensionContext
is a property ofUIViewController
, so if you want to reference it from a view you would need to keep a reference to the parent view controller's extensionContext, or create a protocol that would allow you to call the parent view controller to do whatever you need to be done with the extensionContext.