Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
reichhartd committed Oct 17, 2023
1 parent 9876724 commit 0d32d95
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 41 deletions.
12 changes: 11 additions & 1 deletion packages/expo-application/build/Application.types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-application/build/Application.types.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion packages/expo-application/build/Application.types.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-application/build/Application.types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/expo-application/ios/ApplicationModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class ApplicationModule: Module {
}
}

AsyncFunction("getApplicationReleaseTypeAsync") { () -> String in
AsyncFunction("getApplicationReleaseTypeAsync") { () -> Int in
let mainProvisioningProfile = ApplicationModuleProvisioningProfile.mainProvisioningProfile
return mainProvisioningProfile.appReleaseType()
return mainProvisioningProfile.appReleaseType().rawValue
}

AsyncFunction("getPushNotificationServiceEnvironmentAsync") { () -> String? in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
import ExpoModulesCore

class ApplicationModuleProvisioningProfile {
private var plist: [String: Any]?

static let mainProvisioningProfile: ApplicationModuleProvisioningProfile = {
let plist = readProvisioningProfilePlist()
return ApplicationModuleProvisioningProfile(plist: plist)
}()

private init(plist: [String: Any]?) {
self.plist = plist
}
private let plist = readProvisioningProfilePlist()
static let mainProvisioningProfile = ApplicationModuleProvisioningProfile()

func notificationServiceEnvironment() -> String? {
guard let plist = plist else {
Expand All @@ -22,30 +14,30 @@ class ApplicationModuleProvisioningProfile {
return entitlements?["aps-environment"] as? String
}

func appReleaseType() -> String {
func appReleaseType() -> AppReleaseType {
guard let provisioningPath = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") else {
#if targetEnvironment(simulator)
return AppReleaseType.simulator.rawValue
return .simulator
#else
return AppReleaseType.appStore.rawValue
return .appStore
#endif
}

guard let mobileProvision = plist else {
return AppReleaseType.unknown.rawValue
return .unknown
}

if let provisionsAllDevices = mobileProvision["ProvisionsAllDevices"] as? Bool, provisionsAllDevices {
return AppReleaseType.enterprise.rawValue
return .enterprise
}
if let provisionedDevices = mobileProvision["ProvisionedDevices"] as? [String], !provisionedDevices.isEmpty {
let entitlements = mobileProvision["Entitlements"] as? [String: Any]
if let getTaskAllow = entitlements?["get-task-allow"] as? Bool, getTaskAllow {
return AppReleaseType.dev.rawValue
return .dev
}
return AppReleaseType.adHoc.rawValue
return .adHoc
}
return AppReleaseType.appStore.rawValue
return .appStore
}

private static func readProvisioningProfilePlist() -> [String: Any]? {
Expand All @@ -64,20 +56,20 @@ class ApplicationModuleProvisioningProfile {
if let plistData = plistString.data(using: .utf8) {
return try PropertyListSerialization.propertyList(from: plistData, options: [], format: nil) as? [String: Any]
}
print("Failed to convert plistString to UTF-8 encoded data object.")
log.error("Failed to convert plistString to UTF-8 encoded data object.")
return nil
} catch {
print("Error reading provisioning profile: \(error.localizedDescription)")
log.error("Error reading provisioning profile: \(error.localizedDescription)")
return nil
}
}
}

enum AppReleaseType: String, Enumerable {
case unknown
case simulator
case enterprise
case dev
case adHoc
case appStore
enum AppReleaseType: Int, Enumerable {
case unknown = 0
case simulator = 1
case enterprise = 2
case dev = 3
case adHoc = 4
case appStore = 5
}
19 changes: 11 additions & 8 deletions packages/expo-application/src/Application.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// @docsMissing
export type ApplicationReleaseType =
| 'unknown'
| 'simulator'
| 'enterprise'
| 'dev'
| 'adHoc'
| 'appStore';
export enum ApplicationReleaseType {
UNKNOWN = 0,
SIMULATOR = 1,
ENTERPRISE = 2,
DEVELOPMENT = 3,
AD_HOC = 4,
APP_STORE = 5,
}

// @docsMissing
/**
* Maps to the [`aps-environment`](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) key in the native target's registered entitlements.
*/
export type PushNotificationServiceEnvironment = 'development' | 'production' | null;

0 comments on commit 0d32d95

Please sign in to comment.