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

Release/8.0.0 #307

Merged
merged 10 commits into from
Jul 9, 2024
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "io.qonversion.sandwich:sandwich:4.5.0"
implementation "io.qonversion.sandwich:sandwich:5.0.2"
}

afterEvaluate { project ->
Expand Down
31 changes: 7 additions & 24 deletions android/src/main/java/com/reactlibrary/QonversionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.qonversion.sandwich.PurchaseResultListener;
import io.qonversion.sandwich.QonversionEventsListener;
import io.qonversion.sandwich.QonversionSandwich;
import io.qonversion.sandwich.SandwichError;
Expand All @@ -26,8 +25,6 @@ public class QonversionModule extends ReactContextBaseJavaModule implements Qonv

private static final String EVENT_ENTITLEMENTS_UPDATED = "entitlements_updated";

private static final String ERROR_CODE_PURCHASE_CANCELLED_BY_USER = "PURCHASE_CANCELLED_BY_USER";

private DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter = null;

public QonversionModule(ReactApplicationContext reactContext) {
Expand Down Expand Up @@ -85,7 +82,7 @@ public void syncHistoricalData() {

@ReactMethod
public void purchase(String productId, @Nullable String offerId, @Nullable Boolean applyOffer, final Promise promise) {
qonversionSandwich.purchase(productId, offerId, applyOffer, getPurchaseResultListener(promise));
qonversionSandwich.purchase(productId, offerId, applyOffer, Utils.getResultListener(promise));
}

@ReactMethod
Expand All @@ -103,7 +100,7 @@ public void updatePurchase(
applyOffer,
oldProductId,
updatePolicyKey,
getPurchaseResultListener(promise)
Utils.getResultListener(promise)
);
}

Expand Down Expand Up @@ -214,30 +211,16 @@ public void detachUserFromRemoteConfiguration(final String remoteConfigurationId
qonversionSandwich.detachUserFromRemoteConfiguration(remoteConfigurationId, Utils.getResultListener(promise));
}

@ReactMethod
public void isFallbackFileAccessible(final Promise promise) {
qonversionSandwich.isFallbackFileAccessible(Utils.getResultListener(promise));
}

@Override
public void onEntitlementsUpdated(@NonNull Map<String, ?> map) {
final WritableMap payload = EntitiesConverter.convertMapToWritableMap(map);
if (eventEmitter != null) {
eventEmitter.emit(EVENT_ENTITLEMENTS_UPDATED, payload);
}
}

private PurchaseResultListener getPurchaseResultListener(final Promise promise) {
return new PurchaseResultListener() {
@Override
public void onSuccess(@NonNull Map<String, ?> map) {
final WritableMap payload = EntitiesConverter.convertMapToWritableMap(map);
promise.resolve(payload);
}

@Override
public void onError(@NonNull SandwichError error, boolean isCancelled) {
if (isCancelled) {
Utils.rejectWithError(error, promise, ERROR_CODE_PURCHASE_CANCELLED_BY_USER);
} else {
Utils.rejectWithError(error, promise);
}
}
};
}
}
230 changes: 230 additions & 0 deletions example/android/app/src/main/assets/qonversion_android_fallbacks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"products": [
{
"id": "android_installment",
"duration": 1,
"store_id": "gb7_test_subscription",
"type": 1,
"base_plan_id": "monthly-installment"
},
{
"id": "android_prepaid_2",
"duration": null,
"store_id": "daniel_prepaid",
"type": 1,
"base_plan_id": "monthly"
},
{
"id": "dan_test",
"duration": null,
"store_id": "dan_test_annual",
"type": null
},
{
"id": "gb6_annual",
"duration": 4,
"store_id": "gb6_test",
"type": 0,
"base_plan_id": "annual"
},
{
"id": "gb6_monthly",
"duration": 1,
"store_id": "gb6_test",
"type": 0,
"base_plan_id": "monthly"
},
{
"id": "gb6_weekly",
"duration": 0,
"store_id": "gb6_test",
"type": 1,
"base_plan_id": "weekly"
},
{
"id": "android_prepaid",
"duration": 2,
"store_id": "gp5_test_subscription_4",
"type": 1,
"base_plan_id": "prepaid-3m"
},
{
"id": "weekly",
"duration": 0,
"store_id": "gp5_test_subscription_4",
"type": 1,
"base_plan_id": "monthly-2"
},
{
"id": "consumable",
"duration": null,
"store_id": "qonversion_inapp_sample",
"type": 2
},
{
"id": "subs_plus_trial",
"duration": 1,
"store_id": "gp5_test_subscription_4",
"type": 0
},
{
"id": "annual",
"duration": 4,
"store_id": "article_test_trial",
"type": 0
},
{
"id": "in_app",
"duration": null,
"store_id": "qonversion_sample_purchase",
"type": 2
}
],
"offerings": [
{
"id": "main",
"tag": 1,
"products": [
{
"id": "weekly",
"duration": 0,
"store_id": "gp5_test_subscription_4",
"type": 1,
"base_plan_id": "monthly-2"
},
{
"id": "annual",
"duration": 4,
"store_id": "article_test_trial",
"type": 0
},
{
"id": "consumable",
"duration": null,
"store_id": "qonversion_inapp_sample",
"type": 2
}
]
},
{
"id": "discounted_offer",
"tag": 0,
"products": []
}
],
"products_permissions": {
"android_installment": [
"standart"
],
"android_prepaid_2": [
"premium"
],
"dan_test": [
"test_permission"
],
"gb6_annual": [
"premium"
],
"gb6_monthly": [
"plus"
],
"gb6_weekly": [
"standart"
],
"android_prepaid": [
"premium"
],
"weekly": [
"plus"
],
"consumable": [],
"subs_plus_trial": [
"standart"
],
"annual": [
"standart",
"sample"
],
"in_app": [
"Premium Movies"
]
},
"remote_config_list": [
{
"experiment": null,
"payload": {
"CTA": "Start Trial",
"CTA_color": "#307BF6",
"main_image": "[IMAGE_URL]",
"product_id": "prod_7d_trial_5.99",
"show_close_button": true
},
"source": {
"assignment_type": "auto",
"context_key": "main_paywall",
"name": "default paywall",
"type": "remote_configuration",
"uid": "0dcb1bd9-9bc3-4668-84aa-4540d1042c5d"
}
},
{
"experiment": null,
"payload": {
"CTA": "Start you trial",
"CTA_color": "red",
"main_image": "111",
"product_id": "123123123123123",
"show_close_button": true
},
"source": {
"assignment_type": "auto",
"context_key": "trulala",
"name": "Default settings",
"type": "remote_configuration",
"uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
}
},
{
"experiment": null,
"payload": {
"test_key": "test_value"
},
"source": {
"assignment_type": "auto",
"context_key": "test_context_key",
"name": "Test with context key1",
"type": "remote_configuration",
"uid": "c5077ec4-acf4-41ea-8b43-05114be5d7ce"
}
},
{
"experiment": null,
"payload": {
"test_key_2": "test_value_2"
},
"source": {
"assignment_type": "auto",
"context_key": "test_context_key_2",
"name": "Test with context key2 - copy",
"type": "remote_configuration",
"uid": "1c000f2a-2f4b-4736-b5dd-75b13bf73deb"
}
},
{
"experiment": null,
"payload": {
"bool": true,
"json": {
"key": "value"
}
},
"source": {
"assignment_type": "auto",
"context_key": "swift_key ",
"name": "Swift",
"type": "remote_configuration",
"uid": "9f85d738-56d8-4f6c-b54a-c08658be2cb4"
}
}
]
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.74.0
FLIPPER_VERSION=0.125.0
org.gradle.jvmargs=-Xmx4608m
14 changes: 14 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target 'example' do

pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec', :modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'fmt', :modular_headers => false

post_install do |installer|
react_native_post_install(
Expand All @@ -42,6 +43,19 @@ target 'example' do
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)

installer.pods_project.targets.each do |target|
if target.name == 'Flipper'
file_path = 'Pods/Flipper/xplat/Flipper/FlipperTransportTypes.h'
contents = File.read(file_path)
unless contents.include?('#include <functional>')
File.open(file_path, 'w') do |file|
file.puts('#include <functional>')
file.puts(contents)
end
end
end
end
end
end

Expand Down
Loading
Loading