简体   繁体   English

如何从iMessage扩展程序打开托管应用程序?

[英]How to open the hosting app from an iMessage extension?

Say I have an iMessage app extension MyMessageApp , it's an extension of MyContainApp . 假设我有一个iMessage应用程序扩展MyMessageApp ,它是MyContainApp的扩展。

What I Expect 我期望什么

When I click a message in iMessage, I want to launch MyContainApp and do something with the message in MyContainApp. 当我单击iMessage中的消息时,我要启动MyContainApp并对MyContainApp中的消息进行某些操作。

Code in didSelectMessage didSelectMessage代码

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

Problem 问题

The result success is always NO 结果success永远是NO

Can an iMessage app extension open the hosting App or not? iMessage应用扩展可以打开托管应用吗?

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 这是我发现的( 对我没有帮助 ), 苹果公司工作人员说:“应该在种子3中修复”苹果公司工作人员说:“将在下一版本中修复” ,2016年8月10日

Still, I can't launch MyContainApp. 不过,我无法启动MyContainApp。 Did I miss anything or there is a new policy about iMessage apps? 我是否错过任何事情,或者关于iMessage应用程序有新政策吗?

I was creating the wrong application! 我创建了错误的应用程序!

First created that MyContainApp 首先创建MyContainApp

and the wrong way to create MyMessageApp is "new->target->Application->iMessageApplication" . 创建MyMessageApp的错误方法是“ new-> target-> Application-> iMessageApplication”。

What I should do is "new->target->Application Extension->iMessage Extension" 我应该做的是“新建->目标->应用程序扩展-> iMessage扩展”

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");
    }
}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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