Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PurchaseTester: allow HTTP requests and enable setting ProxyURL #1917

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

if let proxyURL = Constants.proxyURL {
Purchases.proxyURL = URL(string: proxyURL)!
}

Purchases.configure(withAPIKey: Constants.apiKey,
appUserID: nil,
observerMode: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ enum Constants {
#error("Must define your Public SDK key here")
static let apiKey = "REVENUECAT_API_KEY"

// Server URL. Can be set to something else to use a proxy.
static let proxyURL: String? = nil

}
5 changes: 5 additions & 0 deletions Tests/TestingApps/PurchaseTester/PurchaseTester/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
3 changes: 3 additions & 0 deletions Tests/TestingApps/PurchaseTesterSwiftUI/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ struct Constants {
#error("Modify this property to reflect your app's API key, then comment this line out.")
static let apiKey = "REVENUECAT_API_KEY"

// Server URL. Can be set to something else to use a proxy.
static let proxyURL: String? = nil

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<true/>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
2CF4286328637559007E6A78 /* RevenueCat.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RevenueCat.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2CF428682863EEAC007E6A78 /* Package+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Package+Extensions.swift"; sourceTree = "<group>"; };
57FD7B2628DA6A44009CA4E4 /* RevenueCat.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RevenueCat.framework; sourceTree = BUILT_PRODUCTS_DIR; };
57FD7B2E28DA6EC4009CA4E4 /* PurchaseTester--macOS--Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "PurchaseTester--macOS--Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -154,6 +155,7 @@
2CD2C4E8278C9B01005D1CC2 = {
isa = PBXGroup;
children = (
57FD7B2E28DA6EC4009CA4E4 /* PurchaseTester--macOS--Info.plist */,
2CCAF2AB286232EB0004E2CA /* Constants.swift */,
2C8C610D27CEBEF200F86F21 /* PurchaseTester--iOS--Info.plist */,
2C52C5DF27B17AA500FEA965 /* Packages */,
Expand Down Expand Up @@ -551,6 +553,7 @@
CURRENT_PROJECT_VERSION = 1;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "PurchaseTester--macOS--Info.plist";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -577,6 +580,7 @@
CURRENT_PROJECT_VERSION = 1;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "PurchaseTester--macOS--Info.plist";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ struct PurchaseTesterApp: App {
.with(usesStoreKit2IfAvailable: true)
.build()

if let proxyURL = Constants.proxyURL {
Purchases.proxyURL = URL(string: proxyURL)!
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add this and the http support changes to the MagicWeather apps? Not sure of the use cases for this, so it might not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more of an example app. I think the Jira was specific for these because these apps are more geared towards testing internal functionality. @aboedo might have more insight into the motivation for this change though, but I'd say we don't need to do that there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly, these changes are meant for the purchase testing apps, which are internal.
The other ones are meant for customers to have an idea of what an app with RC installed looks like and have code that they can copy and paste


Purchases.logLevel = .debug
Purchases.configure(with: configuration)
Purchases.shared.delegate = self.delegate
Expand Down