-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
111 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ A valid API key is needed in order to use the Forethought Solve SDK. In additon | |
|
||
### Groovy | ||
|
||
```groovy | ||
```groovy | ||
// add the jitpack maven repository to the project repositories, this can exist | ||
// inside project's build.gradle, or settings.gradle. | ||
repositories { | ||
|
@@ -21,13 +21,13 @@ repositories { | |
// add the dependency to the app's build.gradle | ||
dependencies { | ||
// Solve Android SDK | ||
implementation "ai.forethought:solve-android-source:1.2.0" | ||
implementation "ai.forethought:solve-android-source:1.3.0" | ||
} | ||
``` | ||
``` | ||
|
||
### Kotlin | ||
|
||
```kotlin | ||
```kotlin | ||
// add the jitpack maven repository to the project repositories, this can exist | ||
// inside project's build.gradle, or settings.gradle. | ||
repositories { | ||
|
@@ -40,147 +40,154 @@ repositories { | |
// add the dependency to the app's build.gradle | ||
dependencies { | ||
// Solve Android SDK | ||
implementation("ai.forethought:solve-android-source:1.2.0") | ||
implementation("ai.forethought:solve-android-source:1.3.0") | ||
} | ||
``` | ||
``` | ||
|
||
## Basic Usage | ||
|
||
1. Inside the Android Application class, add the following lines to the onCreate() method: | ||
|
||
```java | ||
Forethought.INSTANCE.setup("FORETHOUGHT_API_KEY") | ||
``` | ||
```java | ||
Forethought.INSTANCE.setup("FORETHOUGHT_API_KEY") | ||
``` | ||
|
||
2. Replace `FORETHOUGHT_API_KEY` with a valid Forethought API key | ||
|
||
3. To show / hide the Forethought Solve SDK, add the following in the `Activity/Fragment`: | ||
|
||
```java | ||
Forethought.INSTANCE.show(); | ||
Forethought.INSTANCE.hide(); | ||
``` | ||
```java | ||
Forethought.INSTANCE.show(); | ||
Forethought.INSTANCE.hide(); | ||
``` | ||
|
||
|
||
## Additional Usage | ||
|
||
### Data Parameters | ||
|
||
To send data parameters, add the following before calling `.show()`: | ||
A comprehensive list of non workflow context variable parameters can be found [here.](https://support.forethought.ai/hc/en-us/articles/1500002917301-Installation-Guide-for-Solve-Widget#:~:text=Additional%20Attributes) To pass widget parameters, add any or all the following before calling `.show()`: | ||
|
||
```java | ||
// Java | ||
Map<String, String> dataParameters = new HashMap<>(); | ||
dataParameters.put("language", "EN"); | ||
dataParameters.put("tracking-email", "[email protected]"); | ||
Forethought.INSTANCE.setDataParameters(dataParameters); | ||
- `dataParameters` will be prefixed with `data-ft-` | ||
- `configParameters` will be prefixed with `config-ft-` | ||
- `additionalParameters` will NOT be prefixed | ||
|
||
// Kotlin | ||
val dataParameters = mapOf( | ||
"language" to "EN", | ||
"tracking-email" to "[email protected]" | ||
) | ||
Forethought.INSTANCE.dataParameters = dataParameters | ||
``` | ||
```java | ||
// Java | ||
Map<String, String> dataParameters = new HashMap<>(); | ||
dataParameters.put("language", "EN"); | ||
dataParameters.put("tracking-email", "[email protected]"); | ||
Forethought.INSTANCE.setDataParameters(dataParameters); | ||
|
||
// Kotlin | ||
val dataParameters = mapOf( | ||
"language" to "EN", | ||
"tracking-email" to "[email protected]" | ||
) | ||
Forethought.INSTANCE.dataParameters = dataParameters | ||
``` | ||
|
||
### Handoffs | ||
|
||
To handoff from Forethought to another helpdesk / provider, implement the following: | ||
|
||
1. Make sure the `Activity/Fragment` implements the ForethoughtListener interface, and override it's methods. The methods | ||
do have default implementations so they are optional. | ||
```java | ||
// Java | ||
public class MainActivity extends AppCompatActivity implements ForethoughtListener { | ||
|
||
```java | ||
// Java | ||
public class MainActivity extends AppCompatActivity implements ForethoughtListener { | ||
// ... | ||
@Override | ||
public void forethoughtHandoffRequested(@NonNull ForethoughtHandoffData forethoughtHandoffData) { | ||
// Custom handoff action | ||
// ... | ||
@Override | ||
public void forethoughtHandoffRequested(@NonNull ForethoughtHandoffData forethoughtHandoffData) { | ||
// Custom handoff action | ||
// ... | ||
|
||
// if handoff was successful | ||
Forethought.INSTANCE.sendHandoffResponse(true); | ||
|
||
// if handoff was unsuccessful | ||
Forethought.INSTANCE.sendHandoffResponse(false); | ||
|
||
// hide Forethought after sendHandoffResponse | ||
Forethought.INSTANCE.hide(); | ||
} | ||
|
||
@Override | ||
public void onWidgetClosed() { | ||
// Custom close action | ||
} | ||
|
||
@Override | ||
public void onWidgetError() { | ||
// handle when the webview doesn't render the widget | ||
} | ||
|
||
// if handoff was successful | ||
Forethought.INSTANCE.sendHandoffResponse(true); | ||
|
||
// if handoff was unsuccessful | ||
Forethought.INSTANCE.sendHandoffResponse(false); | ||
|
||
// hide Forethought after sendHandoffResponse | ||
Forethought.INSTANCE.hide(); | ||
} | ||
|
||
// Kotlin | ||
class MainActivity : AppCompatActivity(), ForethoughtListener { | ||
// ... | ||
override fun forethoughtHandoffRequested(handoffData: ForethoughtHandoffData) { | ||
// Custom handoff action | ||
// ... | ||
@Override | ||
public void onWidgetClosed() { | ||
// Custom close action | ||
// Called when customer closes the widget or when onBackPressed is triggered | ||
} | ||
|
||
// if handoff was successful | ||
Forethought.INSTANCE.sendHandoffResponse(true) | ||
@Override | ||
public void onWidgetError() { | ||
// handle when the webview doesn't render the widget | ||
} | ||
} | ||
|
||
// if handoff was unsuccessful | ||
Forethought.INSTANCE.sendHandoffResponse(false) | ||
// Kotlin | ||
class MainActivity : AppCompatActivity(), ForethoughtListener { | ||
// ... | ||
override fun forethoughtHandoffRequested(handoffData: ForethoughtHandoffData) { | ||
// Custom handoff action | ||
// ... | ||
|
||
// hide Forethought after sendHandoffResponse | ||
Forethought.INSTANCE.hide() | ||
} | ||
// if handoff was successful | ||
Forethought.INSTANCE.sendHandoffResponse(true) | ||
|
||
override fun onWidgetClosed() { | ||
// Custom close action | ||
} | ||
// if handoff was unsuccessful | ||
Forethought.INSTANCE.sendHandoffResponse(false) | ||
|
||
override fun onWidgetError() { | ||
// handle when the webview doesn't render the widget | ||
} | ||
// hide Forethought after sendHandoffResponse | ||
Forethought.INSTANCE.hide() | ||
} | ||
``` | ||
|
||
2. In the onCreate method, add the `Activity/Fragment` as a listener to the Forethought Solve SDk: | ||
```java | ||
// Java | ||
@Override | ||
protected void onCreate(...) { | ||
super.onCreate(savedInstanceState); | ||
// ... | ||
Forethought.INSTANCE.addListener(this); | ||
override fun onWidgetClosed() { | ||
// Custom close action | ||
// Called when customer closes the widget or when onBackPressed is triggered | ||
} | ||
|
||
// Kotlin | ||
override fun onCreate(...) { | ||
super.onCreate(savedInstanceState) | ||
// ... | ||
Forethought.INSTANCE.addListener(this) | ||
override fun onWidgetError() { | ||
// handle when the webview doesn't render the widget | ||
} | ||
``` | ||
} | ||
``` | ||
|
||
2. In the onCreate method, add the `Activity/Fragment` as a listener to the Forethought Solve SDk: | ||
```java | ||
// Java | ||
@Override | ||
protected void onCreate(...) { | ||
super.onCreate(savedInstanceState); | ||
// ... | ||
Forethought.INSTANCE.addListener(this); | ||
} | ||
|
||
// Kotlin | ||
override fun onCreate(...) { | ||
super.onCreate(savedInstanceState) | ||
// ... | ||
Forethought.INSTANCE.addListener(this) | ||
} | ||
``` | ||
|
||
3. Don't forget to remove the listener on the `onDestory` of the `Activity/Fragment` to prevent memory leaks. | ||
```java | ||
// Java | ||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
// Remove the listener once the activity is destroyed. | ||
Forethought.INSTANCE.removeListener(this); | ||
} | ||
```java | ||
// Java | ||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
// Remove the listener once the activity is destroyed. | ||
Forethought.INSTANCE.removeListener(this); | ||
} | ||
|
||
// Kotlin | ||
override fun onDestroy() { | ||
super.onDestroy() | ||
// Remove the listener once the activity is destroyed. | ||
Forethought.INSTANCE.removeListener(this) | ||
} | ||
``` | ||
// Kotlin | ||
override fun onDestroy() { | ||
super.onDestroy() | ||
// Remove the listener once the activity is destroyed. | ||
Forethought.INSTANCE.removeListener(this) | ||
} | ||
``` | ||
|
||
|
||
### Plugins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters