I am designing a sdk where I am making some url call at some point of time. 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 is in form of library which some third party app will import and use. I have the reference of UIViewController
which is invoking the url call in third party app. I have no idea if having only UIViewController reference is enough or not.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.