Skip to content

Sift import is undefined while trying to run with android #14

@atwalg2

Description

@atwalg2

The error I am getting is:
Cannot read property 'setSiftConfig' of null

The problem seems to be that Sift package is not being imported properly

Other details:
package.json

   "react-native": "0.69.2",
   "sift-react-native": "^0.1.7",

android/build.gradle

buildscript {
    ext {
        compileSdkVersion = 33
        buildToolsVersion = "33.0.0"

        minSdkVersion = 23
        targetSdkVersion = 33

        ndkVersion = "21.4.7075529"

        supportAppCompatVersion = 'androidx.appcompat:appcompat:1.3.1'
        kotlinVersion = "1.6.20"
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'https://maven.google.com' }
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.3.0"
        classpath "com.facebook.react:react-native-gradle-plugin"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
        maven {
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url 'https://jitpack.io' }
    }

    tasks.withType(JavaCompile) {
        sourceCompatibility = 1.7
        targetCompatibility = 1.7
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked"
        }
    }
}
        
        
        

Here is how I am trying to use it in my app

import Sift from "sift-react-native";

function App() {

   useEffect(() => {
         Sift.setSiftConfig(
            SIFT_CONFIG.SIFT_ACCOUNT_ID,
            SIFT_CONFIG.BEACON_KEY,
            true,
            Platform.select({
              android: SIFT_CONFIG.MOBILE_EVENT_URL.ANDROID,
              ios: SIFT_CONFIG.MOBILE_EVENT_URL.IOS,
            }) as string,
          );
   }, [])

   return (
         <>
           // code
         </>
   )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions