2016-09-22 17 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。該對象可以爲您打開網址。

相關問題