2

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 enter image description here

How can I open a url from my footer in my message extension? Is this possible?

blue
  • 7,175
  • 16
  • 81
  • 179

1 Answers1

0

It looks like you're calling extensionContext on your FooterCollectionReusableView. extensionContext is a property of UIViewController, 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.

Samantha
  • 2,269
  • 2
  • 13
  • 25
  • Yes but the problem is the url doesn't open even in the messageviewcontroller - it just completes the completion block, but doesnt open safari – blue Dec 25 '16 at 19:10
  • 2
    It might be because the Today extension is technically the only extension that’s supposed to open other apps. This question would be more specific http://stackoverflow.com/questions/38319433/can-imessage-extension-open-host-app – Samantha Dec 25 '16 at 21:56