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
let categories = [ | |
"55a5a1ebe4b013909087cbb6" : "🍝", // AbruzzoRestaurant | |
"5294c7523cf9994f4e043a62" : "🍓", // AcaiHouse | |
"4bf58dd8d48988d102951735" : "💄", // AccessoriesStore | |
"52960eda3cf9994f4e043ac9" : "🍴", // AcehneseRestaurant | |
"52e81612bcbc57f1066b7a3b" : "🏥", // Acupuncturist | |
"56aa371ce4b08b9a8d573570" : "🏫", // Adult Education Centers | |
"5267e446e4b0ec79466e48c4" : "👗", // AdultBoutique | |
"52e81612bcbc57f1066b7a3d" : "🏢", // AdvertisingAgency | |
"503288ae91d4c4b30a586d67" : "🍴", // AfghanRestaurant |
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 fireNotification(title: String?, body: String?, id: String) { | |
let content = UNMutableNotificationContent() | |
if let title = title { | |
content.title = title | |
} | |
if let body = body { | |
content.body = body != "" ? body : "arrival" | |
} | |
content.sound = UNNotificationSound.default() |
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
import Foundation | |
enum AppConfiguration : String { | |
case debug = "debug" | |
case testFlight = "testFlight" | |
case appStore = "appStore" | |
} | |
struct Config { | |
// This is private because the use of 'appConfiguration' is preferred. |
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
@available(iOS 12.2, *) | |
func showPromoUpsell() { | |
Purchases.shared.entitlements { (entitlements, error) in | |
// 1: - Get the discount for the product we want to offer | |
// | |
guard let product = entitlements?["pro_cat"]?.offerings["monthly_cats"]?.activeProduct else { | |
print("Error finding monthly_cat product") | |
return |
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 configureCatContentFor(purchaserInfo: PurchaserInfo?) { | |
if let purchaserInfo = purchaserInfo { | |
if purchaserInfo.activeEntitlements.contains("pro_cat") { | |
// ... | |
// ... | |
// ... | |
} else { |
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 shouldShowSubscriptionOffer(_ purchaserInfo: PurchaserInfo) -> Bool { | |
// Check that the user has a 'pro_cat' entitlement that expired >= 7 days ago | |
// and check that we haven't previously shown this offer to the user | |
if (purchaserInfo.expirationDate(forEntitlement: "pro_cat") ?? Date()).addingTimeInterval(7*86400) <= Date() && | |
!UserDefaults.standard.bool(forKey: "has_seen_promo_cat_discount") | |
{ | |
return true | |
} |
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
@available(iOS 12.2, *) | |
func showPromoUpsell() { | |
Purchases.shared.entitlements { (entitlements, error) in | |
// 1: - Get the discount for the product we want to offer | |
// | |
guard let product = entitlements?["pro_cat"]?.offerings["monthly_cats"]?.activeProduct else { | |
print("Error finding monthly_cat product") | |
return |
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
// 2: - Fetch the payment discount | |
// | |
Purchases.shared.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, err) in | |
guard let discount = paymentDiscount else { | |
print("Payment discount doesn't exist. Check error.") | |
return | |
} | |
// ... continued |
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
// 3: - Show the user the offer to purchase and save a flag | |
// in local storage so we don't show again | |
self.presentPromoAlert(productDiscount, shouldPurchase: { | |
Purchases.shared.makePurchase(product, discount: discount, { (transaction, info, error, cancelled) in | |
self.configureCatContentFor(purchaserInfo: info) | |
}) | |
}) | |
// ... continued |
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
import Purchases | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { |
OlderNewer