Skip to main content

Add Kettle

Preqrequisites

The following criterias must be fulfilled to implement the SDK:

  • Minimum iOS target: 11.0
  • CocoaPods installed on target machine
  • Android Jetpack artifacts (AndroidX)
  • Minimum Android minSdk: 15
  • Minimum Android compileSdk: 31
  • Minimum Kotlin version: 1.8.10

Add dependency

The module is available from npmjs. Install the module and run pod install:

$ yarn add react-native-kettle-module -E
$ pod install

Android

IMPORTANT

A runtime exception will be thrown on launch if API key is missing.

Automatic Initialization

In AndroidManifest.xml, add the following element as a child of the application element:

AndroidManifest.xml
<meta-data
android:name="com.kogenta.kettle.sdk.API_KEY"
android:value="<API-KEY>"
/>

Manual initialization

IMPORTANT

A runtime exception will be thrown if the SDK is interacted with before initialization.

In AndroidManifest.xml, add the following element as a child of the application element:

AndroidManifest.xml
<provider
android:name="com.kogenta.kettle.core.api.KettleInitializer"
android:authorities="${applicationId}.KettleInitializer"
tools:node="remove"
/>

In MainApplication.java, add the following code for initialization:

MainApplication.java
import com.kogenta.kettle.common.config.KettleConfig;
import com.kogenta.kettle.common.logging.LogLevel;
import com.kogenta.kettle.sdk.Kettle;
...
@Override
public void onCreate() {
super.onCreate();

...

KettleConfig kettleConfig = new KettleConfig();
kettleConfig.setDevelopmentApiKey("<dev-api-key>");
kettleConfig.setProductionApiKey("<prod-api-key>");
kettleConfig.setDevelopmentLogLevel(LogLevel.TRACE); // optional - defaults to INFO
kettleConfig.setProductionLogLevel(LogLevel.INFO); // optional - default to INFO
kettleConfig.setInProduction(false); // optional - defaults to true
Kettle.initialize(kettleConfig, getApplicationContext());
}
...

If the project does not build due to missing symbols, add the following dependency to your applications build.gradle:

build.gradle
dependencies {
...
implementation("com.kogenta.kettle:kettle-sdk:1.2.0")
...
}

Declare repository manually

In certain versions of React Native, the SDK is unable to be fetched from the repository and will result in a build failure. Add a reference to the repository holding the artifacts if this is the case:

build.gradle
allprojects {
repositories {
maven { url = "https://artifacts.kogenta.com/release" }
}
}

iOS

After running pod install, navigate to your projects ios directory and open the xcworkspace.

In your AppDelegate didFinishLaunchingWithOptions, add the following to initialize Kettle:

import KettleKit
...
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...

let kettleConfig = KettleConfig.default()
kettleConfig.developmentApiKey = "<DEV-API-KEY">
kettleConfig.productionApiKey = "<PROD-API-KEY">

// optionally, override Kettle's default log verbosity
kettleConfig.productionLogLevel = .none
kettleConfig.developmentLogLevel = .debug

// Initialize Kettle
Kettle.prepare(config, launchOptions: launchOptions)

...
}
#import <KettleKit/KettleKit.h>
#import <KettleKit/KettleKit-Swift.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...

KTLConfig* config = [KTLConfig KTLDefaultConfig];
config.productionApiKey = @"kettleProductionKey";
config.developmentApiKey = @"kettleDevelopmentKey";

// optionally, override Kettle's default log verbosity
config.productionLogLevel = KTLLogLevelNone;
config.developmentLogLevel = KTLLogLevelDebug;

// Initialize Kettle
[KTLKettle prepare:config launchOptions:launchOptions];

...
}

Add bluetooth-central to your applications background modes. This is required to scan for eddystone data. Add the required permissions to your Info.plist.

Import Kettle in React

You can import Kettle in your project as:

import { Kettle } from 'react-native-kettle-module';