美文网首页
iOS检测app下载源头

iOS检测app下载源头

作者: 跃文 | 来源:发表于2019-08-01 09:33 被阅读0次
  • Method 1
if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
    // 下载自TestFlight
} else {
    // 下载自App Store (and Apple reviewers too)
}
  • Method 2
BOOL isDownLoadFromTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];

Swift

/// 是否是 testflight包
public static var isTestFlight: Bool {
    return isAppStoreReceiptSandbox && !hasEmbeddedMobileProvision
 }
/// 是否是 Appstore 包
 public static var isAppStore: Bool {
    return isAppStoreReceiptSandbox || hasEmbeddedMobileProvision ? false : true
 }
 fileprivate static var isAppStoreReceiptSandbox: Bool {
    return Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
 }
 fileprivate static var hasEmbeddedMobileProvision: Bool {
    return Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil
 }

相关文章

网友评论

      本文标题:iOS检测app下载源头

      本文链接:https://www.haomeiwen.com/subject/leifdctx.html