gpt4 book ai didi

ios - 从今日扩展中以编程方式从plist获取URL方案

转载 作者:行者123 更新时间:2023-12-01 22:21:06 24 4
gpt4 key购买 nike

最终,我试图通过以下方式从Widget启动Main应用

UIApplication.SharedApplication.OpenUrl(new NSUrl("MyURLScheme//"));

所以我有一个带有今天扩展名的iOS应用程序。我想访问主应用程序的URL方案。那可能吗?我的URL方案位于我的主应用程序的Plist文件中,而不是今天的扩展名。我可以只从主应用程序中引用一个吗?我尝试从CFBundleURLTypes和CFBundleURLSchemes获取它,但它们都显示为“null”。
可能是因为它在窗口小部件的Plist中查找,而不是在主应用程序的Plist中查找。
var asdf2 = NSBundle.MainBundle.InfoDictionary["CFBundleURLTypes"];
var asdf3 = NSBundle.MainBundle.InfoDictionary["CFBundleURLSchemes"];

这是URL方案在主应用程序的Plist文件中的位置的屏幕截图。我希望不必在今天的扩展程序的Plist文件中存储重复的信息。而且我也不想不必将URL Scheme硬编码为今天的扩展的代码。

enter image description here

最佳答案

会是(丑陋的)这样的东西:

var arr = (NSBundle.MainBundle.InfoDictionary["CFBundleURLTypes"] as NSMutableArray);
var urlTypes = arr.GetItem<NSDictionary>(0);
var schemes = urlTypes.ObjectForKey(new NSString("CFBundleURLSchemes")) as NSMutableArray;
var scheme = schemes.GetItem<NSString>(0).ToString();

关于ios - 从今日扩展中以编程方式从plist获取URL方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44836010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com