mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
feat: gate download behind development certificate on iOS
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'CheckIosCertificate'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'A sample project summary'
|
||||
s.description = 'A sample project description'
|
||||
s.author = ''
|
||||
s.homepage = 'https://docs.expo.dev/modules/'
|
||||
s.platforms = { :ios => '13.4', :tvos => '13.4' }
|
||||
s.source = { git: '' }
|
||||
s.static_framework = true
|
||||
|
||||
s.dependency 'ExpoModulesCore'
|
||||
|
||||
# Swift/Objective-C compatibility
|
||||
s.pod_target_xcconfig = {
|
||||
'DEFINES_MODULE' => 'YES',
|
||||
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
||||
}
|
||||
|
||||
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
||||
end
|
@@ -0,0 +1,37 @@
|
||||
import ExpoModulesCore
|
||||
|
||||
public class CheckIosCertificateModule: Module {
|
||||
// Each module class must implement the definition function. The definition consists of components
|
||||
// that describes the module's functionality and behavior.
|
||||
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
||||
public func definition() -> ModuleDefinition {
|
||||
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
||||
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
||||
// The module will be accessible from `requireNativeModule('CheckIosCertificate')` in JavaScript.
|
||||
Name("CheckIosCertificate")
|
||||
|
||||
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
||||
Function("isDevelopmentProvisioningProfile") {
|
||||
#if targetEnvironment(simulator)
|
||||
// Running on the Simulator
|
||||
return true
|
||||
#else
|
||||
// Check for provisioning profile for non-Simulator execution
|
||||
guard let filePath = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") else {
|
||||
return false
|
||||
}
|
||||
|
||||
let fileURL = URL(fileURLWithPath: filePath)
|
||||
do {
|
||||
let data = try String(contentsOf: fileURL, encoding: .ascii)
|
||||
let cleared = data.components(separatedBy: .whitespacesAndNewlines).joined()
|
||||
return cleared.contains("<key>get-task-allow</key><true/>")
|
||||
} catch {
|
||||
// Handling error if the file read fails
|
||||
print("Error reading provisioning profile: \(error)")
|
||||
return false
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user