[英]Access Bundle Identifier of App in Custom Framework
I am designing a sdk where I am making some url call at some point of time. 我正在设计一个SDK,在某个时间点要进行一些url调用。 For this I want the context of the app which is making a call.
为此,我需要正在打电话的应用程序的上下文。 As a context I want to pass the bundle identifier of the app using that sdk.
作为上下文,我想使用该sdk传递应用程序的包标识符。
SDK is in form of library which some third party app will import and use. SDK采用库的形式,某些第三方应用程序将导入和使用该库。 I have the reference of
UIViewController
which is invoking the url call in third party app. 我有
UIViewController
的引用,该引用正在第三方应用程序中调用url调用。 I have no idea if having only UIViewController reference is enough or not. 我不知道是否只有UIViewController引用就足够了。
So how can I get access to bundle identifier of their app? 那么,如何获得他们应用程序的捆绑包标识符?
Thanks 谢谢
Very simple 很简单
// VC is ref to the class object of the main app
// This will give the class type of the object
let objectType = type(of: vc)
//This will get you the bundle of the main app
let bundle = Bundle(for: objectType.self)
// This will finally give you the bundle
let bundleId = bundle.bundleIdentifier
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.