IMPORTANT NOTE: This readme provides the minimal required steps for integration. For more detailed and explained documentation, you can find it on our website
- ReactNative 0.63 and above
npm install @anagog/jedai
- Xcode version 13.0 or newer.
- iOS version 11.0 or newer.
Note: Xcode/Swift version depends on the SDK version. SDKs are always built with the latest Xcode version at the time of the release. If you need the SDK built to a specific version, please contact Anagog Customer Support, and we will provide it.
- Go to Signing & Capabilities tab and add the following capablities:
- Background Modes: Background fetch and Remote notifications.
- Access WiFi Information.
- Add the following entries to the Info.plist:
-
Permitted background task scheduler identifiers
, and then add new item with the valuecom.anagog.jedai.sdk.refresh
. -
ANAGOG_API_KEY
, and put API KEY that you received from Anagog.
-
// TODO: Change JemaReactNativeSampleApp by your project name
#import "JemaReactNativeSampleApp-Swift.h"
@import JedAIReactNative;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[JedAIAppWrapper.shared start];
return YES;
}
// For iOS 11 and iOS 12 only
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler {
[JedAIAppWrapper.shared refresh];
completionHandler(UIBackgroundFetchResultNewData);
}
// ...
@end
In cross-platform frameworks, Anagog SDK can be configured with the anagog_config.json
file located in:
Android - In your android project assets folder android/src/main/assets/anagog_config.json
iOS - In your root iOS project folder ios/anagog_config.json
More information you can find here
- compileSdkVersion: 31
- targetSdkVersion: 30
- minSdkVersion: 21
buildscript {
ext {
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
}
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
- SDK Configuration in AndroidManifest.xml
- Set SDK License Key
- Foregraound service notification title string resourse
- Foreground service notification message setring resourse
- Foreground service notification icon resourse
<application
android:name=...
android:theme="@style/AppTheme">
<meta-data android:name="ANAGOG_API_KEY"
android:value="api key as received from Anagog"/>
<meta-data android:name="ANAGOG_NOTIFICATION_ICON"
android:resource="@mipmap/ic_launcher_round"/>
</application>
- Define foreground service string resources
<resources>
...
<string name="anagog_foreground_title">notification title</string>
<string name="anagog_foreground_message">notification body</string>
</resources>
- SDK Config json file
- Create anagog_config.json file in project android/app/src/main directory
- Add the following content with SDK configuration
{
"userDefinedStats": {
"Age" : "INTEGER",
"Gender" : "STRING",
"Score" : "DECIMAL",
"AppLaunchCount": "INTEGER",
"OnBoardingCompleted": "STRING"
},
"notificationChannelId": "AwesomeApp",
"foregroundChannelId": "AwesomeApp_FG",
"enableAudienceAnalytics" : true,
"foregroundAlwaysOn" : false,
"enableLatestMs": true,
"enableCrashReports": true,
"enableInternalLog" : true,
"jedaiAutoEnabled" : true
}
import { AnagogReactNative, ApplicationEvent, JEMAUserInteractionEvent, JEMAUserInteractionEventTriggerType, AnagogEventType, JedAIStatus } from '@anagog/jedai';
AnagogReactNative.obtainEventStream((action, payload) => {
switch (action) {
case AnagogEventType.onCampaignTriggered: {
break;
}
case AnagogEventType.onNotificationClick: {
var identifier = payload["campaign_identifier"];
console.log('onNotificationClick Campaign Identifier:', identifier);
var event = new JEMAUserInteractionEvent(identifier, JEMAUserInteractionEventTriggerType.conversion);
AnagogReactNative.sendUserInteractionEvent(event);
break;
}
case AnagogEventType.onSnapshotReport: {
break;
}
case AnagogEventType.onJedAIStatusChange: {
if (payload == JedAIStatus.active)
console.log('JedAI is active');
else if (payload == JedAIStatus.passive)
console.log('JedAI is not running');
break;
}
}
});
Note: Please do not use those APIs in production
// Download
AnagogReactNative.syncCampaigns()
// Simulate
AnagogReactNative.simulateCampaign() // - all
AnagogReactNative.simulateCampaign('campaignId') // - specific
// Get all available campaigns
let campaigns = await AnagogReactNative.getCampaigns();
// Fetch values
let name = await AnagogReactNative.getUserDefinedString('name');
let age = await AnagogReactNative.getUserDefinedInteger('age');
let score = await AnagogReactNative.getUserDefinedDecimal('score');
// Set values
AnagogReactNative.setUserDefinedString('name', 'Alesander');
AnagogReactNative.setUserDefinedInteger('age', 67);
AnagogReactNative.setUserDefinedDecimal('score', 97.5);
let micromoment = new ApplicationEvent('Registration');
micromoment.addTextParameter('Status', 'Completed');
AnagogReactNative.fireMicromoment(micromoment);
You can fire micromoment also this way:
let micromoment = new ApplicationEvent('Registration');
micromoment.addTextParameter('Status', 'Completed');
micromoment.fire();
let event = new JEMAUserInteractionEvent("campaignId", JEMAUserInteractionEventTriggerType.conversion); AnagogReactNative.sendUserInteractionEvent(event);
You can send user interaction event also this way:
let event = new JEMAUserInteractionEvent("campaignId", JEMAUserInteractionEventTriggerType.conversion); event.send();
// Force schedule reports
AnagogReactNative.forceScheduleReports();
//Request microsegments snapshot report
AnagogReactNative.requestMicrosegmentsSnapshotReport();
// Start JedAI
// NOTICE: After calling thing method, JedAI will start automatically on each app start in foreground and background modes.
await AnagogReactNative.enableJedAI();
// Stop JedAI
// NOTICE: JedAI will not start even after app restart until you won't call 'startupJedAI' method.
await AnagogReactNative.disableJedAI();
// Get JedAI status
let status = await AnagogReactNative.getJedAIStatus();
// Share feedback
AnagogReactNative.share();
// Get JedAI SDK Version
let jedaiVersion = await AnagogReactNative.getVersion();
Anagog SDK is not open source software or public software. It is the proprietary software of Anagog Ltd. and, unless otherwise agreed in writing with Anagog Ltd., no rights are granted to you in respect of the SDK. This SDK is subject to, and may only be used in accordance with the terms of (and obligations imposed by) a separate commercial license agreement with Anagog Ltd.
You may not copy or use this SDK in any manner without first entering into an agreement with and obtaining a license from Anagog Ltd.
In order to request a license to use this SDK and an activation key from Anagog Ltd., please contact Anagog Ltd. directly at info@anagog.com.
Anagog Ltd. reserves the right, in its sole discretion, to grant or reject requests for licenses to this SDK.