Skip to content

SDK-114: Release Flutter SDK version 1.1.2 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.packages
.idea/
.DS_Store
example/android/app/google-services.json
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## CHANGE LOG

### Version 1.1.2 (May 20, 2020)
* Adds support for Product Config and Feature Flags
* Adds support for Custom Handling Push Amplification Campaigns
* Supports CleverTap Android and iOS SDK v3.8.0

### Version 1.1.1 (March 30, 2020)
* Adds support for Custom App Inbox
* Adds support for InApp/Inbox button click listeners
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To add the CleverTap Flutter SDK to your project, edit your project's `pubspec.y

```yaml
dependencies:
clevertap_plugin: 1.1.1
clevertap_plugin: 1.1.2
```

Run `flutter packages get` to install the SDK
Expand All @@ -36,7 +36,7 @@ Add the following to your `dependencies` section in `project/build.gradle`

Add the following to your `dependencies` section in `app/build.gradle`
```groovy
implementation 'com.clevertap.android:clevertap-android-sdk:3.7.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.8.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'//Mandatory for using FCM push notifications, skip if not using FCM
implementation 'com.android.support:appcompat-v7:28.0.0'//MANDATORY for App Inbox
Expand Down Expand Up @@ -106,7 +106,7 @@ Add your CleverTap Account ID and Token to your `AndroidManifest.xml`, within th

After install, you will need to integrate the CleverTap SDK into your apps.

1. Follow the integration instructions [starting with Step 2 here](https://support.clevertap.com/docs/ios/getting-started.html).
1. Follow the integration instructions [starting with Step 2 here](https://developer.clevertap.com/docs/ios-quickstart-guide#section-step-2-add-clever-tap-credentials).
2. In your `AppDelegate didFinishLaunchingWithOptions:` notify the CleverTap Flutter SDK of application launch:
```objc
[CleverTap autoIntegrate]; // integrate CleverTap SDK using the autoIntegrate option
Expand Down
3 changes: 2 additions & 1 deletion android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.clevertap.clevertap_plugin'
version '1.1'
version '1.1.2'

buildscript {
repositories {
Expand Down Expand Up @@ -41,7 +41,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.7.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.8.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import com.clevertap.android.sdk.CTExperimentsListener;
import com.clevertap.android.sdk.CTFeatureFlagsListener;
import com.clevertap.android.sdk.CTInboxListener;
import com.clevertap.android.sdk.CTInboxMessage;
import com.clevertap.android.sdk.CTInboxStyleConfig;
import com.clevertap.android.sdk.CTPushListener;
import com.clevertap.android.sdk.CleverTapAPI;
import com.clevertap.android.sdk.EventDetail;
import com.clevertap.android.sdk.InAppNotificationButtonListener;
import com.clevertap.android.sdk.InAppNotificationListener;
import com.clevertap.android.sdk.InboxMessageButtonListener;
import com.clevertap.android.sdk.Logger;
import com.clevertap.android.sdk.SyncListener;
import com.clevertap.android.sdk.UTMDetail;
import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
import com.clevertap.android.sdk.product_config.CTProductConfigListener;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

Expand All @@ -40,7 +48,9 @@
public class CleverTapPlugin implements MethodCallHandler, SyncListener,
InAppNotificationListener, CTInboxListener,
CTExperimentsListener, InAppNotificationButtonListener,
InboxMessageButtonListener, DisplayUnitListener {
InboxMessageButtonListener, DisplayUnitListener,
CTFeatureFlagsListener, CTProductConfigListener,
CTPushListener {

private static final String TAG = "CleverTapPlugin";
private static final String ERROR_MSG = "CleverTap Instance is not initialized";
Expand All @@ -62,6 +72,9 @@ private CleverTapPlugin(Activity activity) {
this.cleverTapAPI.setInAppNotificationListener(this);
this.cleverTapAPI.setSyncListener(this);
this.cleverTapAPI.setDisplayUnitListener(this);
this.cleverTapAPI.setCTFeatureFlagsListener(this);
this.cleverTapAPI.setCTProductConfigListener(this);
this.cleverTapAPI.setCTPushListener(this);
this.cleverTapAPI.setLibrary("Flutter");
}
}
Expand Down Expand Up @@ -103,10 +116,26 @@ public void onMethodCall(MethodCall call, Result result) {
}

case "createNotification": {
String extras = call.argument("extras");
if (isCleverTapNotNull(cleverTapAPI)) {
try {
Log.d(TAG, "createNotification Android");
CleverTapAPI.createNotification(context, Utils.stringToBundle(extras));
} catch (JSONException e) {
result.error(TAG, "Unable to render notification due to JSONException - " + e.getLocalizedMessage(), null);
}
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "processPushNotification": {
JSONObject extras = call.argument("extras");
if (isCleverTapNotNull(cleverTapAPI)) {
try {
CleverTapAPI.createNotification(context, Utils.jsonToBundle(extras));
CleverTapAPI.processPushNotification(context, Utils.jsonToBundle(extras));
} catch (JSONException e) {
result.error(TAG, "Unable to render notification due to JSONException - " + e.getLocalizedMessage(), null);
}
Expand Down Expand Up @@ -975,6 +1004,7 @@ public void onMethodCall(MethodCall call, Result result) {
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "pushDisplayUnitClickedEvent": {
Expand All @@ -985,6 +1015,130 @@ public void onMethodCall(MethodCall call, Result result) {
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getFeatureFlag": {
String key = call.argument("key");
boolean defaultValue = call.argument("defaultValue");
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.featureFlag().get(key,defaultValue));
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "setDefaultsMap": {
HashMap<String, Object> defaults = call.argument("defaults");
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().setDefaults(defaults);
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "fetch": {
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().fetch();
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "fetchWithMinimumFetchIntervalInSeconds": {
int interval = call.argument("interval");
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().fetch(interval);
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "activate": {
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().activate();
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "fetchAndActivate": {
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().fetchAndActivate();
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "setMinimumFetchIntervalInSeconds": {
long interval = call.argument("interval");
if (isCleverTapNotNull(cleverTapAPI)) {
cleverTapAPI.productConfig().setMinimumFetchIntervalInSeconds(interval);
result.success(null);
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getLastFetchTimeStampInMillis": {
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.productConfig().getLastFetchTimeStampInMillis());
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getString":{
String key = call.argument("key");
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.productConfig().getString(key));
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getBoolean":{
String key = call.argument("key");
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.productConfig().getBoolean(key));
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getLong":{
String key = call.argument("key");
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.productConfig().getLong(key));
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

case "getDouble":{
String key = call.argument("key");
if (isCleverTapNotNull(cleverTapAPI)) {
result.success(cleverTapAPI.productConfig().getDouble(key));
} else {
result.error(TAG, ERROR_MSG, null);
}
break;
}

//no-op for android, methods only for iOS.
Expand Down Expand Up @@ -1084,4 +1238,29 @@ public void onInboxButtonClick(HashMap<String, String> payload) {
public void onDisplayUnitsLoaded(ArrayList<CleverTapDisplayUnit> units) {
invokeMethodOnUiThread("onDisplayUnitsLoaded", Utils.displayUnitListToArrayList(units));
}

@Override
public void featureFlagsUpdated() {
invokeMethodOnUiThread("featureFlagsUpdated", "");
}

@Override
public void onInit() {
invokeMethodOnUiThread("productConfigInitialized", "");
}

@Override
public void onFetched() {
invokeMethodOnUiThread("productConfigFetched", "");
}

@Override
public void onActivated() {
invokeMethodOnUiThread("productConfigActivated", "");
}

@Override
public void onPushPayloadReceived(Bundle extras) {
invokeMethodOnUiThread("pushAmpPayloadReceived",Utils.bundleToMap(extras));
}
}
23 changes: 23 additions & 0 deletions android/src/main/java/com/clevertap/clevertap_plugin/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

public class Utils {
static Map<String,Object> eventDetailToMap(EventDetail eventDetail){
Expand Down Expand Up @@ -222,4 +223,26 @@ static HashMap<String, Object> dartMapToProfileMap(Map<String, Object> profileMa
}
return profile;
}

static Map<String, Object> bundleToMap(Bundle extras) {
Map<String, Object> map = new HashMap<String, Object>();

Set<String> ks = extras.keySet();
for (String key : ks) {
map.put(key, extras.get(key));
}
return map;
}

static Bundle stringToBundle(String content) throws JSONException {
JSONObject jsonObject = new JSONObject(content);
Bundle bundle = new Bundle();
Iterator iter = jsonObject.keys();
while(iter.hasNext()){
String key = (String)iter.next();
String value = jsonObject.getString(key);
bundle.putString(key,value);
}
return bundle;
}
}
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.7.2'
implementation 'com.clevertap.android:clevertap-android-sdk:3.8.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.android.support:appcompat-v7:28.0.0'//MANDATORY for App Inbox
Expand Down
Loading