Skip to content
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
36 changes: 23 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNIterable_' + name]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this line doing? Getting the project name from new arch vs. old arch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No -- it's either getting the value of a parameter in the users app or, if it doesn't exist, getting the value in our sdk

}

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

def reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}
Expand Down Expand Up @@ -63,7 +59,11 @@ android {
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
}

buildFeatures {
buildConfig true
}

buildTypes {
Expand All @@ -80,6 +80,19 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch']
} else {
java.srcDirs += ['src/oldarch']
}
}
}

// Add this to match the Iterable SDK group ID
group = "com.iterable"
}

repositories {
Expand All @@ -90,10 +103,7 @@ repositories {
def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "com.iterable:iterableapi:3.5.2"
// api project(":iterableapi") // links to local android SDK repo rather than by release
Expand Down
12 changes: 6 additions & 6 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RNIterable_kotlinVersion=1.7.0
RNIterable_minSdkVersion=21
RNIterable_targetSdkVersion=31
RNIterable_compileSdkVersion=31
RNIterable_ndkversion=21.4.7075529
RNIterable_kotlinVersion=2.0.21
RNIterable_minSdkVersion=24
RNIterable_targetSdkVersion=35
RNIterable_compileSdkVersion=35
RNIterable_ndkversion=27.1.12297006
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;

import com.iterable.iterableapi.InboxSessionManager;
import com.iterable.iterableapi.IterableAction;
Expand All @@ -40,7 +36,6 @@
import com.iterable.iterableapi.IterableLogger;
import com.iterable.iterableapi.IterableUrlHandler;
import com.iterable.iterableapi.RNIterableInternal;
import com.iterable.reactnative.Serialization;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
package com.iterable.reactnative;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

import com.facebook.react.ReactPackage;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.BaseReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;

public class RNIterableAPIPackage implements ReactPackage {
public class RNIterableAPIPackage extends BaseReactPackage {
@Nullable
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();

modules.add(new RNIterableAPIModule(reactContext));

return modules;
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
if (RNIterableAPIModuleImpl.NAME.equals(name)) {
return new RNIterableAPIModule(reactContext);
} else {
return null;
}
}

@NonNull
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
public ReactModuleInfoProvider getReactModuleInfoProvider() {
return new ReactModuleInfoProvider() {
@NonNull
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
moduleInfos.put(RNIterableAPIModuleImpl.NAME, new ReactModuleInfo(
RNIterableAPIModuleImpl.NAME,
RNIterableAPIModuleImpl.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
false, // isCxxModule
isTurboModule // isTurboModule
));
return moduleInfos;
}
};
}
}
Loading
Loading