Skip to content

Commit af91304

Browse files
authored
Merge pull request #33 from apptentive/develop
Release 5.1.4
2 parents 4f494cb + 3c21354 commit af91304

File tree

7 files changed

+53
-11
lines changed

7 files changed

+53
-11
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This document lets you know what has changed in the React Native module. For cha
55
- [Android Changelog](https://github.com/apptentive/apptentive-android/blob/master/CHANGELOG.md)
66
- [iOS Changelog](https://github.com/apptentive/apptentive-ios/blob/master/CHANGELOG.md)
77

8+
# 2018-08-15 - v5.1.4
9+
10+
- Fixed Android build issues
11+
- Improved configuration handling
12+
813
# 2018-07-26 - v5.1.3
914

1015
- Fix check for registered status on iOS

android/src/main/java/com/apptentive/android/sdk/reactlibrary/RNApptentiveModule.java

+43-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import android.support.annotation.Nullable;
77

88
import com.apptentive.android.sdk.Apptentive;
9+
import com.apptentive.android.sdk.ApptentiveConfiguration;
910
import com.apptentive.android.sdk.ApptentiveInternal;
11+
import com.apptentive.android.sdk.ApptentiveLog;
1012
import com.apptentive.android.sdk.conversation.Conversation;
1113
import com.apptentive.android.sdk.conversation.ConversationDispatchTask;
14+
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks;
1215
import com.apptentive.android.sdk.module.messagecenter.UnreadMessagesListener;
1316
import com.apptentive.android.sdk.util.ObjectUtils;
1417
import com.apptentive.android.sdk.util.StringUtils;
@@ -45,7 +48,7 @@ public String getName() {
4548
//region JavaScript bindings
4649

4750
@ReactMethod
48-
public void register(ReadableMap configuration, Promise promise) {
51+
public void register(ReadableMap configurationMap, Promise promise) {
4952
try {
5053
Application application = reactContextWrapper.getApplication();
5154

@@ -55,7 +58,7 @@ public void register(ReadableMap configuration, Promise promise) {
5558
return;
5659
}
5760

58-
Map<String, Object> config = toHashMap(configuration);
61+
Map<String, Object> config = toHashMap(configurationMap);
5962
String apptentiveKey = ObjectUtils.as(config.get("apptentiveKey"), String.class);
6063
if (StringUtils.isNullOrEmpty(apptentiveKey)) {
6164
promise.reject(CODE_APPTENTIVE, "Apptentive key is null or empty");
@@ -68,7 +71,18 @@ public void register(ReadableMap configuration, Promise promise) {
6871
return;
6972
}
7073

71-
Apptentive.register(application, apptentiveKey, apptentiveSignature);
74+
ApptentiveConfiguration configuration = new ApptentiveConfiguration(apptentiveKey, apptentiveSignature);
75+
ApptentiveLog.Level logLevel = parseLogLevel(ObjectUtils.as(config.get("logLevel"), String.class));
76+
if (logLevel != null) {
77+
configuration.setLogLevel(logLevel);
78+
}
79+
80+
Boolean shouldSanitizeLogMessages = ObjectUtils.as(config.get("shouldSanitizeLogMessages"), Boolean.class);
81+
if (shouldSanitizeLogMessages != null) {
82+
configuration.setShouldSanitizeLogMessages(shouldSanitizeLogMessages);
83+
}
84+
85+
Apptentive.register(application, configuration);
7286

7387
ApptentiveInternal instance = ObjectUtils.as(ApptentiveInternal.getInstance(), ApptentiveInternal.class);
7488
if (instance == null) {
@@ -82,9 +96,11 @@ public void register(ReadableMap configuration, Promise promise) {
8296
return;
8397
}
8498

85-
instance.getRegisteredLifecycleCallbacks().onActivityCreated(currentActivity, null);
86-
instance.getRegisteredLifecycleCallbacks().onActivityStarted(currentActivity);
87-
instance.getRegisteredLifecycleCallbacks().onActivityResumed(currentActivity);
99+
ApptentiveActivityLifecycleCallbacks lifecycleCallbacks = ApptentiveActivityLifecycleCallbacks.getInstance();
100+
lifecycleCallbacks.onActivityCreated(currentActivity, null);
101+
lifecycleCallbacks.onActivityStarted(currentActivity);
102+
lifecycleCallbacks.onActivityResumed(currentActivity);
103+
88104
Apptentive.addUnreadMessagesListener(this);
89105
Apptentive.setAuthenticationFailedListener(this);
90106
promise.resolve(Boolean.TRUE);
@@ -93,6 +109,26 @@ public void register(ReadableMap configuration, Promise promise) {
93109
}
94110
}
95111

112+
private ApptentiveLog.Level parseLogLevel(String logLevel) {
113+
if (!StringUtils.isNullOrEmpty(logLevel)) {
114+
switch (logLevel.toLowerCase()) {
115+
case "verbose":
116+
return ApptentiveLog.Level.VERBOSE;
117+
case "debug":
118+
return ApptentiveLog.Level.DEBUG;
119+
case "info":
120+
return ApptentiveLog.Level.INFO;
121+
case "warn":
122+
case "warning":
123+
return ApptentiveLog.Level.WARN;
124+
case "error":
125+
return ApptentiveLog.Level.ERROR;
126+
}
127+
}
128+
129+
return null;
130+
}
131+
96132
@ReactMethod
97133
public void presentMessageCenter(ReadableMap customData, Promise promise) {
98134
try {
@@ -449,4 +485,4 @@ public void onFinish(boolean result) {
449485
}
450486

451487
//endregion
452-
}
488+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="apptentive_distribution">React Native</string>
4-
<string name="apptentive_distribution_version">5.1.3</string>
4+
<string name="apptentive_distribution_version">5.1.4</string>
55
</resources>

apptentive-react-native.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "apptentive-react-native"
3-
s.version = "5.1.3"
3+
s.version = "5.1.4"
44
s.summary = "Apptentive SDK module for React Native"
55

66
s.description = <<-DESC

ios/RNApptentiveModule.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ - (dispatch_queue_t)methodQueue
5252
if (configuration) {
5353
configuration.appID = configurationDictionary[@"appleID"];
5454
configuration.distributionName = @"React Native";
55-
configuration.distributionVersion = @"5.1.3";
55+
configuration.distributionVersion = @"5.1.4";
5656
[Apptentive registerWithConfiguration:configuration];
5757

5858
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageCenterUnreadCountChangedNotification:) name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil];

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apptentive-react-native",
3-
"version": "5.1.3",
3+
"version": "5.1.4",
44
"description": "React Native Module for Apptentive SDK",
55
"main": "js/index.js",
66
"scripts": {

sample/App.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default class App extends Component {
5959

6060
// Override log level (optional)
6161
configuration.logLevel = 'verbose';
62+
configuration.shouldSanitizeLogMessages = false;
6263

6364
// Register Apptentive
6465
Apptentive.register(configuration)

0 commit comments

Comments
 (0)