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

Add support new native majors #485

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ jobs:
- run:
name: Install Pods
working_directory: IntegrationTests/buildiOS
command: pod install --verbose
command: pod install --repo-update --verbose

- save_cache:
key: 1-pods-{{ checksum "RevenueCat/Plugins/Editor/RevenueCatDependencies.xml" }}
Expand Down
4 changes: 2 additions & 2 deletions AMAZON-INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void OnInitialized(IStoreController controller, IExtensionProvider extens
if (product.hasReceipt) {
var amazonExtensions = storeExtensionProvider.GetExtension<IAmazonExtensions>();
var userId = amazonExtensions.amazonUserId;
purchases.SyncObserverModeAmazonPurchase(
purchases.SyncAmazonPurchase(
product.definition.id,
product.transactionID,
userId,
Expand All @@ -55,7 +55,7 @@ public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)

var amazonExtensions = storeExtensionProvider.GetExtension<IAmazonExtensions>();
var userId = amazonExtensions.amazonUserId;
purchases.SyncObserverModeAmazonPurchase(
purchases.SyncAmazonPurchase(
e.purchasedProduct.definition.id,
e.purchasedProduct.transactionID,
userId,
Expand Down
9 changes: 4 additions & 5 deletions IntegrationTests/Assets/APITests/PurchasesAPITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private void Start()
};

purchases.listener = new CustomListener();
purchases.observerMode = true;
purchases.userDefaultsSuiteName = "suitename";
purchases.proxyURL = "https://proxy-url.revenuecat.com";

Expand Down Expand Up @@ -147,7 +146,6 @@ private void Start()
receivedError = error;
});

purchases.SetFinishTransactions(true);
#pragma warning disable CS0618 // Type or member is obsolete
purchases.SetAllowSharingStoreAccount(false);
#pragma warning restore CS0618 // Type or member is obsolete
Expand All @@ -170,7 +168,6 @@ private void Start()
});

purchases.SyncPurchases();
purchases.SetAutomaticAppleSearchAdsAttributionCollection(true);
purchases.EnableAdServicesAttributionTokenCollection();
Dictionary<string, Purchases.IntroEligibility> receivedEligibilities;
purchases.CheckTrialOrIntroductoryPriceEligibility(new string[] { "a", "b" },
Expand Down Expand Up @@ -220,16 +217,18 @@ private void Start()
Purchases.PurchasesConfiguration purchasesConfiguration =
builder.SetUserDefaultsSuiteName("user_default")
.SetDangerousSettings(new Purchases.DangerousSettings(false))
.SetObserverMode(true)
.SetPurchasesAreCompletedBy(Purchases.PurchasesAreCompletedBy.MyApp, Purchases.StoreKitVersion.StoreKit2)
.SetUseAmazon(false)
.SetAppUserId(appUserId)
.SetUsesStoreKit2IfAvailable(false)
.SetStoreKitVersion(Purchases.StoreKitVersion.StoreKit2)
.SetShouldShowInAppMessagesAutomatically(false)
.SetEntitlementVerificationMode(Purchases.EntitlementVerificationMode.Informational)
.SetPendingTransactionsForPrepaidPlansEnabled(true)
.Build();
purchases.Configure(purchasesConfiguration);

purchases.SyncObserverModeAmazonPurchase("product_id", "receipt_id", "amazon_user_id", "iso_currency_code", 1.99);
purchases.SyncAmazonPurchase("product_id", "receipt_id", "amazon_user_id", "iso_currency_code", 1.99);

purchases.ShowInAppMessages(new Purchases.InAppMessageType[] { Purchases.InAppMessageType.BillingIssue,
Purchases.InAppMessageType.PriceIncreaseConsent, Purchases.InAppMessageType.Generic });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ private void Start()
bool IsBasePlan = subscriptionOption.IsBasePlan;
bool IsPrepaid = subscriptionOption.IsPrepaid;
string PresentedOfferingIdentifier = subscriptionOption.PresentedOfferingIdentifier;
Purchases.SubscriptionOption.InstallmentsInfo installmentsInfo = subscriptionOption.OptionInstallmentsInfo;
int commitmentPaymentsCount = installmentsInfo.CommitmentPaymentsCount;
int renewalCommitmentPaymentsCount = installmentsInfo.RenewalCommitmentPaymentsCount;
}
}
}
4 changes: 2 additions & 2 deletions IntegrationTests/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ PlayerSettings:
StripUnusedMeshComponents: 1
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 11.0
iOSTargetOSVersionString: 13.0
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 11.0
tvOSTargetOSVersionString: 13.0
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
Expand Down
22 changes: 8 additions & 14 deletions RevenueCat/Plugins/Android/PurchasesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.revenuecat.purchases.CustomerInfo;
import com.revenuecat.purchases.DangerousSettings;
import com.revenuecat.purchases.Purchases;
import com.revenuecat.purchases.PurchasesAreCompletedBy;
import com.revenuecat.purchases.Store;
import com.revenuecat.purchases.common.PlatformInfo;
import com.revenuecat.purchases.hybridcommon.CommonKt;
Expand Down Expand Up @@ -65,20 +64,20 @@ public void onReceived(@NonNull CustomerInfo customerInfo) {
public static void setup(String apiKey,
String appUserId,
String gameObject,
boolean observerMode,
String purchasesAreCompletedBy,
String userDefaultsSuiteName,
boolean useAmazon,
boolean shouldShowInAppMessagesAutomatically,
String dangerousSettingsJSON,
String entitlementVerificationMode) {
String entitlementVerificationMode,
boolean pendingTransactionsForPrepaidPlansEnabled) {
PurchasesWrapper.gameObject = gameObject;
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
Store store = useAmazon ? Store.AMAZON : Store.PLAY_STORE;
DangerousSettings dangerousSettings = getDangerousSettingsFromJSON(dangerousSettingsJSON);
PurchasesAreCompletedBy completedBy = observerMode ?
PurchasesAreCompletedBy.MY_APP : PurchasesAreCompletedBy.REVENUECAT;
CommonKt.configure(UnityPlayer.currentActivity, apiKey, appUserId, completedBy, platformInfo, store,
dangerousSettings, shouldShowInAppMessagesAutomatically, entitlementVerificationMode);
CommonKt.configure(UnityPlayer.currentActivity, apiKey, appUserId, purchasesAreCompletedBy, platformInfo, store,
dangerousSettings, shouldShowInAppMessagesAutomatically, entitlementVerificationMode,
pendingTransactionsForPrepaidPlansEnabled);
Purchases.getSharedInstance().setUpdatedCustomerInfoListener(listener);
}

Expand Down Expand Up @@ -312,14 +311,14 @@ public void onError(ErrorContainer errorContainer) {
});
}

public static void syncObserverModeAmazonPurchase(
public static void syncAmazonPurchase(
String productID,
String receiptID,
String amazonUserID,
String isoCurrencyCode,
double price
) {
Purchases.getSharedInstance().syncObserverModeAmazonPurchase(productID, receiptID,
Purchases.getSharedInstance().syncAmazonPurchase(productID, receiptID,
amazonUserID, isoCurrencyCode, price);
}

Expand Down Expand Up @@ -357,11 +356,6 @@ public static void getCustomerInfo() {
CommonKt.getCustomerInfo(getCustomerInfoListener(GET_CUSTOMER_INFO));
}

public static void setFinishTransactions(boolean enabled) {
CommonKt.setPurchasesAreCompletedBy(enabled ?
PurchasesAreCompletedBy.REVENUECAT : PurchasesAreCompletedBy.MY_APP);
}

public static void syncPurchases() {
CommonKt.syncPurchases();
}
Expand Down
4 changes: 2 additions & 2 deletions RevenueCat/Plugins/Editor/RevenueCatDependencies.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="com.revenuecat.purchases:purchases-hybrid-common:[11.1.0]" />
<androidPackage spec="com.revenuecat.purchases:purchases-hybrid-common:[13.0.0]" />
<androidPackage spec="androidx.annotation:annotation:[1.2.0]" />
</androidPackages>
<iosPods>
<iosPod name="PurchasesHybridCommon" version="11.1.0" minTargetSdk="11.0"/>
<iosPod name="PurchasesHybridCommon" version="13.0.0" minTargetSdk="13.0"/>
</iosPods>
</dependencies>
35 changes: 8 additions & 27 deletions RevenueCat/Plugins/iOS/PurchasesUnityHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ @implementation RCUnityHelperDelegate
- (void)setupPurchases:(NSString *)apiKey
appUserID:(nullable NSString *)appUserID
gameObject:(NSString *)gameObject
observerMode:(BOOL)observerMode
usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable
purchasesAreCompletedBy:(NSString *)purchasesAreCompletedBy
storeKitVersion:(NSString *)storeKitVersion
userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
dangerousSettingsJson:(NSString *)dangerousSettingsJson
shouldShowInAppMessagesAutomatically:(BOOL)shouldShowInAppMessagesAutomatically
Expand All @@ -86,11 +86,11 @@ - (void)setupPurchases:(NSString *)apiKey

[RCPurchases configureWithAPIKey:apiKey
appUserID:appUserID
purchasesAreCompletedBy:(observerMode ? RCPurchasesAreCompletedByMyApp : RCPurchasesAreCompletedByRevenueCat)
purchasesAreCompletedBy:purchasesAreCompletedBy
userDefaultsSuiteName:userDefaultsSuiteName
platformFlavor:self.platformFlavor
platformFlavorVersion:self.platformFlavorVersion
usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
storeKitVersion:storeKitVersion
dangerousSettings:dangerousSettings
shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically
verificationMode:entitlementVerificationMode];
Expand Down Expand Up @@ -236,18 +236,6 @@ - (void)getCustomerInfo {
[RCCommonFunctionality getCustomerInfoWithCompletionBlock:[self getCustomerInfoCompletionBlockFor:GET_CUSTOMER_INFO]];
}

- (void)setFinishTransactions:(BOOL)finishTransactions {
if (finishTransactions) {
[RCCommonFunctionality setPurchasesAreCompletedBy:RCPurchasesAreCompletedByRevenueCat];
} else {
[RCCommonFunctionality setPurchasesAreCompletedBy:RCPurchasesAreCompletedByMyApp];
}
}

- (void)setAutomaticAppleSearchAdsAttributionCollection:(BOOL)enabled {
[RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:enabled];
}

- (void)enableAdServicesAttributionTokenCollection {
if (@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *)) {
[RCCommonFunctionality enableAdServicesAttributionTokenCollection];
Expand Down Expand Up @@ -507,17 +495,17 @@ - (NSString *)platformFlavorVersion {
void _RCSetupPurchases(const char *gameObject,
const char *apiKey,
const char *appUserID,
const BOOL observerMode,
const BOOL usesStoreKit2IfAvailable,
const char *purchasesAreCompletedBy,
const char *storeKitVersion,
const char *userDefaultsSuiteName,
const char *dangerousSettingsJson,
const BOOL shouldShowInAppMessagesAutomatically,
const char *entitlementVerificationMode) {
[_RCUnityHelperShared() setupPurchases:convertCString(apiKey)
appUserID:convertCString(appUserID)
gameObject:convertCString(gameObject)
observerMode:observerMode
usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
purchasesAreCompletedBy:convertCString(purchasesAreCompletedBy)
storeKitVersion:convertCString(storeKitVersion)
userDefaultsSuiteName:convertCString(userDefaultsSuiteName)
dangerousSettingsJson:convertCString(dangerousSettingsJson)
shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically
Expand Down Expand Up @@ -571,9 +559,6 @@ void _RCLogOut() {
[_RCUnityHelperShared() logOut];
}

void _RCSetFinishTransactions(const BOOL finishTransactions) {
[_RCUnityHelperShared() setFinishTransactions:finishTransactions];
}
void _RCSetAllowSharingStoreAccount(const BOOL allow) {
[_RCUnityHelperShared() setAllowSharingStoreAccount:allow];
}
Expand Down Expand Up @@ -618,10 +603,6 @@ void _RCGetCustomerInfo() {
return [_RCUnityHelperShared() getAppUserID];
}

void _RCSetAutomaticAppleSearchAdsAttributionCollection(const BOOL enabled) {
[_RCUnityHelperShared() setAutomaticAppleSearchAdsAttributionCollection:enabled];
}

void _RCEnableAdServicesAttributionTokenCollection() {
[_RCUnityHelperShared() enableAdServicesAttributionTokenCollection];
}
Expand Down
Loading