2016-09-22 41 views
2

打开我们的应用程序,我已经建立了iMessage的一个应用程序,是工作perfactly,但我想知道我怎么能打开我们的应用程序从iMessage的如何从iMessage的

假设我有后一个应用程序,我加入的iMessage目标和从iMessage我想从iMessage打开我的应用程序可能吗?

我试着用这个,但没有成功

NSString *customURL = @"appName://"; 

if ([[UIApplication sharedApplication] 
canOpenURL:[NSURL URLWithString:customURL]]) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]]; 
    } 

错误:

enter image description here

enter image description here

回答

2

最后问题解决了。我一直在我的应用程序的构建设置再次绊倒在

enter image description here

我第一次设置为YES。虽然默认是NO。当我将它设置为NO时,错误消失。我也对此结果感到震惊

0

我假设你有一个主要的应用程序已经工作(除了iMessage的扩展名)。

转到您的主应用程序的Info.plist创建一个新的URL类型结构类似这样的

URL类型 - > URL方案 - > Your_App_Name_No_Spaces

在此之后,你可以去你的应用程序扩展

NSString *customURL = @"appName://"; 

if ([[UIApplication sharedApplication] 
canOpenURL:[NSURL URLWithString:customURL]]) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]]; 
    } 
+0

检查我更新的问题 –

0

在您的MSMessagesAppViewController的子类中,有一个属性extensionContext,类型为NSExtensionContext。该对象可以为您打开网址。