Open host app from message extension

Is there a way to open host app from message extension? I tried following code, it doesn't work.

if let url = NSURL(string: "appscheme:/

self.extensionContext?.openURL(url, completionHandler: { (success) in

})

}


Updated:

Filed Radar for this radar# 26973978

Accepted Reply

This is apparently not working in Seed 2 but should be fixed in Seed 3.

Replies

I'd be curious to know if the completion block is getting called with true or false for the success.

It's false, can't messages extension use

self.extensionContext openURL:completion

?

This is apparently not working in Seed 2 but should be fixed in Seed 3.

i just did a test. now you can open host app from iMessage extension on beta 4

Doesn't seem to work anymore in beta5

In beta 5 the completion handler returns false and the following prints to console:


MessagesExtension[3000:708889] [Default] openURL: failed: <private>


Can we have some guidance on whether openURL will be allowed in Message extensions? Is this a bug or a new policy? This is critical to how many of us decide to move forward with our apps.


Thanks!


Update:

Looks like it may be a bug:


https://forums.developer.apple.com/thread/54267


"Unfortunately, the ability to open your parent app isn't functioning correctly in Beta 5. This will be fixed in the next release."

Fixed in beta 6!

In beta 6 in Simulator and on device, I can't get this to work:



        if let urlToOpen = URL(string: urlString), let messageExtension = self.extensionContext {
            messageExtension.open(urlToOpen, completionHandler: nil)
        }


So it works for others?

Do you have a "Containing app" for you Messages extension. The behavior I'm seeing in beta 6 is that openURL will only open your containing app, no other app. In my experiments it doesn't even matter if the containing app has registered to handle the URL, openURL will still open the containing app. I even tried "http://apple.com" and it opened the containing app.


If you have no containing app then it fails as it did in Beta 5.

I do not have a containing app. I assumed Messages was my container app. This was working in Beta 4 but not in Beta 5 or 6.


Thanks pinch.