简体   繁体   中英

How to open the hosting app from an iMessage extension?

Say I have an iMessage app extension MyMessageApp , it's an extension of MyContainApp .

What I Expect

When I click a message in iMessage, I want to launch MyContainApp and do something with the message in MyContainApp.

Code in didSelectMessage

self.extensionContext openURL:url completionHandler:^(BOOL success)

Problem

The result success is always NO

Can an iMessage app extension open the hosting App or not?

Here is what I found ( didn't help me ) Apple staff said "should be fixed in seed 3" and Apple staff said "This will be fixed in the next release" in Aug 10,2016

Still, I can't launch MyContainApp. Did I miss anything or there is a new policy about iMessage apps?

I was creating the wrong application!

First created that MyContainApp

and the wrong way to create MyMessageApp is "new->target->Application->iMessageApplication" .

What I should do is "new->target->Application Extension->iMessage Extension"

and the "open host app" code is:

NSString *urlScheme = @"zkbrowser://";
NSURL *url = [NSURL URLWithString:urlScheme];

[self.extensionContext openURL:url completionHandler:^(BOOL success) {
    if (success) {
        NSLog(@">>>success");
    }else{
        NSLog(@">>>fail");
    }
}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM