This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getSomethingFromBackground(completion: @escaping (String)->()) { | |
DispatchQueue.global().async { | |
completion("Hello world!") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UIXibView: UIView { | |
public var nibName:String? { return String(describing: type(of: self)) } | |
public var contentView: UIView! | |
override public init(frame: CGRect) { | |
super.init(frame: frame) | |
awakeFromNib() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override open func awakeFromNib() { | |
super.awakeFromNib() | |
let nibName = String(describing: type(of: self)) | |
guard let view = Bundle.main.loadNibNamed(nibName, owner: self, options: nil)?.first as? UIView else { return } | |
view.frame = self.bounds | |
view.autoresizingMask = [.flexibleHeight,.flexibleWidth] | |
self.addSubview(view) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum AppEnvironments { | |
case Dev, Pre, Pro | |
} | |
var environment: AppEnvironments { | |
get { | |
let bundleId = Bundle.main.bundleIdentifier ?? "" | |
switch bundleId { | |
case "com.timbrit.dev": return .Dev | |
case "com.timbrit.pre": return .Pre |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set here your Environment.plist name | |
ENVIRONMENT="DEV" | |
#Environment.plist path | |
ENVIRONMENT_PLIST="$PROJECT_DIR/AppName/Environments.plist" | |
#Get app name from Environment.plist | |
APP_NAME=$(/usr/libexec/PlistBuddy -c "Print :$ENVIRONMENT:APP_NAME" "$ENVIRONMENT_PLIST") | |
#Get bundle identifier from Environment.plist | |
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :$ENVIRONMENT:BUNDLE_IDENTIFIER" "$ENVIRONMENT_PLIST") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"auto_renew_status_change_date":"2019-09-20 11:13:26 Etc/GMT", | |
"environment":"Sandbox", | |
"auto_renew_status":"false", | |
"auto_renew_status_change_date_pst":"2019-09-20 04:13:26 America/Los_Angeles", | |
"latest_expired_receipt":"ewoJInNpZ25hdHVyZSIgPSAiQTVZc0kwRUFlZER0TWRpalVXYk5rcTJG...", | |
"latest_expired_receipt_info":{ | |
"original_purchase_date_pst":"2019-09-20 03:44:04 America/Los_Angeles", | |
"quantity":"1", | |
"subscription_group_identifier":"205957", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status": 0, | |
"environment": "Sandbox", | |
"receipt": { | |
"receipt_type": "ProductionSandbox", | |
"adam_id": 0, | |
"app_item_id": 0, | |
"bundle_id": "com.company.appName", | |
"application_version": "3583", | |
"download_id": 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"password" : "79b4e6583c2...ca7d504ed97", | |
"receipt-data" : "MIIeZwYJKoZIhvcNAQcCoIIeWDCCHlQCAQExCzAJBgUrDgMCGgUAMIIOCAYJKoZ..." | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var receiptData: String? { | |
guard | |
let url = Bundle.main.appStoreReceiptURL, | |
let data = try? Data(contentsOf: url) | |
else { return nil } | |
return data.base64EncodedString() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func purchase(_ product: SKProduct) { | |
guard SKPaymentQueue.canMakePayments() else { | |
return | |
} | |
let payment = SKPayment(product: product) | |
let queue = SKPaymentQueue.default() | |
queue.add(payment) | |
queue.add(self) //Delegate | |
} |
NewerOlder