@anagog/cordova-jedai
v1.14.0
Published
Anagog SDK Cordova plugin. Use our Cordova plugin to integrate our SDK in your Cordova apps.
Downloads
133
Readme
Integration
Cordova
cordova plugin add @anagog/cordova-jedai
iOS
Requirements
- Xcode version 13.0 or later.
- iOS version 11.0 or later.
Note: Xcode/Swift version - depends on 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.
Info.plist
- Add API key that you received from Anagog.
<key>ANAGOG_API_KEY</key>
<string>PUT HERE YOUR API KEY</string>
Android
Requirements
- compileSdkVersion: 31
- targetSdkVersion: 30
- minSdkVersion: 21
In Cordova you should can set these values in gradle.properties
- cdvSdkVersion = 31
- cdvMinSdkVersion = 21
- 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
AndroidManifest.xml
<application
android:name=...
android:theme="@style/AppTheme">
<meta-data android:name="ANAGOG_API_KEY"
android:value="api key as received from Anagog"/>
<!-- The following 3 elements required if your app needs location services -->
<meta-data android:name="ANAGOG_NOTIFICATION_ICON"
android:resource="@mipmap/ic_launcher"/>
<meta-data android:name="ANAGOG_FOREGROUND_TITLE"
android:resource="@string/anagog_foreground_title"/>
<meta-data android:name="ANAGOG_FOREGROUND_MESSAGE"
android:resource="@string/anagog_foreground_title"/>
</application>
- Define foreground service string resources
strings.xml
<resources>
...
<string name="anagog_foreground_title">notification title</string>
<string name="anagog_foreground_message">notification body</string>
</resources>
- SDK Config json file
When installing Anagog Cordova plugin, it will add a default anagog_config.json file in android/app/src/main/assets directory
This file can be used to configure essentials features in the SDK
- Open anagog_config.json file in project android/app/src/main/assets directory
- Set your preferred configuration
- The file structure should be like this:
android/app/src/main/assets/anagog_config.json
{
"userDefinedStats": {
"StringUserDefinedStat" : "STRING", //Set a String type CustomMicroSegment
"IntegerUserDefinedStat" : "INTEGER", //Set an Integer type CustomMicroSegment
"DecimalUserDefinedStat" : "DECIMAL", //Set a Decimal type CustomMicroSegment
},
"notificationChannelId": "", //Fill with your own app channel name
"foregroundChannelId": "", //Fill with your own app channel name
"enableAudienceAnalytics" : true,
"foregroundMode" : "NEVER", //Available values: NEVER, ON_DEMAND, ALWAYS
"enableLatestMs": true,
"enableCrashReports": true,
"enableInternalLog" : true,
"jedaiAutoEnabled" : true
}
Usage
SDK Notifications
AnagogCordova.obtainEventStream((action, payload) => {
switch (action) {
case AnagogEventType.onCampaignTriggered: {
break;
}
case AnagogEventType.onNotificationClick: {
var identifier = payload["campaign_identifier"];
console.log('onNotificationClick Campaign Identifier:', identifier);
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;
}
}
});
Campaigns
Note: Please do not use those APIs in production
// Download
AnagogCordova.syncCampaigns()
// Simulate
AnagogCordova.simulateCampaign() // - all
AnagogCordova.simulateCampaign('campaignId') // - specific
// Get all available campaigns
AnagogCordova.getCampaigns(campaigns => {
// `campaigns` is a list of objects
})
Microsegments
// Fetch values
AnagogCordova.getUserDefinedString('name', (name) => {
// `name` is a string value
})
AnagogCordova.getUserDefinedInteger('age', (age) => {
// `age` is a number value
})
AnagogCordova.getUserDefinedDecimal('score', (score) => {
// `score` is a number value
})
// Set values
AnagogCordova.setUserDefinedString('name', 'Alesander');
AnagogCordova.setUserDefinedInteger('age', 67);
AnagogCordova.setUserDefinedDecimal('score', 97.5);
Micromoments
let micromoment = new ApplicationEvent('Registration');
micromoment.addTextParameter('Status', 'Completed');
AnagogCordova.fireMicromoment(micromoment);
You can fire micromoment also this way:
let micromoment = new ApplicationEvent('Registration');
micromoment.addTextParameter('Status', 'Completed');
micromoment.fire();
Reports
// Force schedule reports
AnagogCordova.forceScheduleReports();
//Request microsegments snapshot report
AnagogCordova.requestMicrosegmentsSnapshotReport();
JedAI
// Get JedAI status
AnagogCordova.getJedAIStatus(status => {
// Status may be `JedAIStatus.active` or `JedAIStatus.passive`
});
// Share feedback
AnagogCordova.share();
// Get JedAI SDK Version
AnagogCordova.getVersion(jedaiVersion => {
// `jedaiVersion` is a string
})
License
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 [email protected].
Anagog Ltd. reserves the right, in its sole discretion, to grant or reject requests for licenses to this SDK.