Skip to content

Commit

Permalink
Fixed minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
al-af committed Nov 6, 2024
1 parent 593d755 commit dd0624b
Show file tree
Hide file tree
Showing 21 changed files with 306 additions and 358 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android/gradlew.bat
android/gradle
android/gradlew
android/.project
android/.settings

# node.js
#
Expand Down Expand Up @@ -66,4 +67,5 @@ demos/appsflyer-expo-app/.expo
demos/appsflyer-expo-app/node_modules
demos/appsflyer-expo-app/yarn.lock

demos/appsflyer-react-native-app/ios/.xcode.env
demos/appsflyer-react-native-app/ios/AppsFlyerExample.xcodeproj/project.pbxproj
9 changes: 4 additions & 5 deletions Docs/RN_PurchaseConnector.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ For more information please check the following pages:
* [Android Purchase Connector](https://dev.appsflyer.com/hc/docs/purchase-connector-android)
* [iOS Purchase Connector](https://dev.appsflyer.com/hc/docs/purchase-connector-ios)

🛠 In order for us to provide optimal support, we would kindly ask you to submit any issues to
[email protected]
🛠 You can contact AppsFlyer support through the Customer Assistant Chatbot for assistance with troubleshooting issues or product guidance. To do so, please follow this article: https://support.appsflyer.com/hc/en-us/articles/23583984402193-Using-the-Customer-Assistant-Chatbot.

> *When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.*
Expand Down Expand Up @@ -205,7 +204,7 @@ You can register listeners to get the validation results once getting a response

The AppsFlyer SDK React Native plugin acts as a bridge between your React Native app and the underlying native SDKs provided by AppsFlyer. It's crucial to understand that the native infrastructure of iOS and Android is quite different, and so is the AppsFlyer SDK built on top of them. These differences are reflected in how you would handle callbacks separately for each platform.

In the iOS environment, there is a single callback method `didReceivePurchaseRevenueValidationInfo` to handle both subscriptions and in-app purchases. You set this callback using `onReceivePurchaseRevenueValidationInfo`.
In the iOS environment, there is a single callback method `didReceivePurchaseRevenueValidationInfo` to handle both subscriptions and in-app purchases. You set this callback using `OnReceivePurchaseRevenueValidationInfo`.

On the other hand, Android segregates callbacks for subscriptions and in-app purchases. It provides two separate listener methods - `onSubscriptionValidationResultSuccess` and `onSubscriptionValidationResultFailure` for subscriptions and `onInAppValidationResultSuccess` and `onInAppValidationResultFailure` for in-app purchases. These listener methods register callback handlers for `OnResponse` (executed when a successful response is received) and `OnFailure` (executed when a failure occurs, including due to a network exception or non-200/OK response from the server).

Expand Down Expand Up @@ -267,7 +266,7 @@ const handleOnReceivePurchaseRevenueValidationInfo = (validationResult) => {
let purchaseRevenueValidationListener;

if (Platform.OS === 'ios') {
purchaseRevenueValidationListener = AppsFlyerPurchaseConnector.onReceivePurchaseRevenueValidationInfo(handleOnReceivePurchaseRevenueValidationInfo);
purchaseRevenueValidationListener = AppsFlyerPurchaseConnector.OnReceivePurchaseRevenueValidationInfo(handleOnReceivePurchaseRevenueValidationInfo);
}
};
}, []);
Expand Down Expand Up @@ -351,7 +350,7 @@ const handleValidationSuccess = (validationResult) => {
subscriptionValidationFailureListener = AppsFlyerPurchaseConnector.onSubscriptionValidationResultFailure(handleSubscriptionValidationFailure);
} else {
console.log('>> Creating purchaseRevenueValidationListener ');
purchaseRevenueValidationListener = AppsFlyerPurchaseConnector.onReceivePurchaseRevenueValidationInfo(handleOnReceivePurchaseRevenueValidationInfo);
purchaseRevenueValidationListener = AppsFlyerPurchaseConnector.OnReceivePurchaseRevenueValidationInfo(handleOnReceivePurchaseRevenueValidationInfo);
}

// Cleanup function
Expand Down
8 changes: 0 additions & 8 deletions PurchaseConnector/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
class AppsFlyerConstants {
static readonly RE_CONFIGURE_ERROR_MSG: string = "[PurchaseConnector] Re configure instance is not permitted. Returned the existing instance";
static readonly MISSING_CONFIGURATION_EXCEPTION_MSG: string = "Could not create an instance without configuration";

// Adding method constants
static readonly SUBSCRIPTION_VALIDATION_SUCCESS: string = 'subscriptionValidationSuccess';
static readonly SUBSCRIPTION_VALIDATION_FAILURE: string = 'subscriptionValidationFailure';
Expand All @@ -13,11 +10,6 @@ class AppsFlyerConstants {
// Adding key constants
static readonly RESULT: string = "result";
static readonly ERROR: string = "error";
static readonly VALIDATION_INFO: string = "validationInfo";
static readonly CONFIGURE_KEY: string = "configure";
static readonly LOG_SUBS_KEY: string = "logSubscriptions";
static readonly LOG_IN_APP_KEY: string = "logInApps";
static readonly SANDBOX_KEY: string = "sandbox";
}

export default AppsFlyerConstants;
2 changes: 1 addition & 1 deletion PurchaseConnector/utils/connector_callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IosError, JVMThrowable } from "../models";
export type PurchaseConnectorListener = (data: any) => void;

// Type definition for a listener which gets called when the `PurchaseConnectorImpl` receives purchase revenue validation info for iOS.
export type onReceivePurchaseRevenueValidationInfo = (validationInfo?: Map<string, any>, error?: IosError) => void;
export type OnReceivePurchaseRevenueValidationInfo = (validationInfo?: Map<string, any>, error?: IosError) => void;

// Invoked when a 200 OK response is received from the server.
// Note: An INVALID purchase is considered to be a successful response and will also be returned by this callback.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 9 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" // Kotlin plugin
}
}


apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' // Apply Kotlin Android plugin

def includeConnector = project.hasProperty('appsflyer.enable_purchase_connector') ? project.property('appsflyer.enable_purchase_connector').toBoolean() : false // Moved outside of android block

Expand All @@ -32,20 +33,18 @@ android {
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
00
}

buildConfigField 'boolean', 'INCLUDE_CONNECTOR', includeConnector.toString()
}

sourceSets {
main {
java.srcDirs = ['src/main/java']
java.srcDirs = ['src/main/java', 'src/main/kotlin'] // Add Kotlin source directory
java.srcDirs += includeConnector ? ['src/main/includeConnector'] : ['src/main/excludeConnector']
}
includeConnector ? ['src/main/includeConnector'] : ['src/main/excludeConnector']
}

lintOptions {
warning 'InvalidPackage'
}
Expand All @@ -57,6 +56,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions { // Configure Kotlin-specific options
jvmTarget = "1.8"
}
}

repositories {
Expand All @@ -65,10 +67,11 @@ repositories {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.10" // Add Kotlin standard library
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.15.1')}"
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.2')}"
if (includeConnector){
implementation 'com.appsflyer:purchase-connector:2.0.1'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@

public class PCAppsFlyerModule extends ReactContextBaseJavaModule {

private ReactApplicationContext reactContext;
private Application application;

public PCAppsFlyerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
this.application = (Application) reactContext.getApplicationContext();
Log.d("AppsFlyer", "PurchaseConnector inclusion status: " + BuildConfig.INCLUDE_CONNECTOR);
}

Expand Down
Loading

0 comments on commit dd0624b

Please sign in to comment.