簡體   English   中英

自定義框架中應用程序的訪問捆綁包標識符

[英]Access Bundle Identifier of App in Custom Framework

我正在設計一個SDK,在某個時間點要進行一些url調用。 為此,我需要正在打電話的應用程序的上下文。 作為上下文,我想使用該sdk傳遞應用程序的包標識符。

SDK采用庫的形式,某些第三方應用程序將導入和使用該庫。 我有UIViewController的引用,該引用正在第三方應用程序中調用url調用。 我不知道是否只有UIViewController引用就足夠了。

那么,如何獲得他們應用程序的捆綁包標識符?

謝謝

很簡單

// 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM