Skip to content

Commit

Permalink
Merge pull request #198 from apptentive/develop
Browse files Browse the repository at this point in the history
Release 6.0.1
  • Loading branch information
frankus authored Jun 9, 2022
2 parents de71f14 + f63f203 commit 50376ac
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ This document lets you know what has changed in the React Native module. For cha
- [Android Changelog](https://github.com/apptentive/apptentive-android/blob/master/CHANGELOG.md)
- [iOS Changelog](https://github.com/apptentive/apptentive-ios/blob/master/CHANGELOG.md)

# 2022-06-09 - v6.0.1

- Apptentive Android SDK: 5.8.3
- Apptentive iOS SDK: 6.0.2

#### Bugs Fixed

- Added missing lifecycle callbacks for the Android platform

# 2022-05-16 - v6.0.0

- Apptentive Android SDK: 5.8.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.app.Application
import com.apptentive.android.sdk.Apptentive
import com.apptentive.android.sdk.ApptentiveConfiguration
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks
import com.apptentive.android.sdk.ApptentiveLog
import com.apptentive.android.sdk.module.messagecenter.UnreadMessagesListener
import com.facebook.react.bridge.*
Expand All @@ -12,6 +13,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule

class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext),
UnreadMessagesListener {

private val APPTENTIVE_ERROR_CODE = "Apptentive Error"
private val EVT_UNREAD_MESSAGE_COUNT_CHANGE = "onUnreadMessageCountChanged"

// React context allows us to get the Application context and the current Activity context
Expand All @@ -22,10 +25,22 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
fun register(credentials: ReadableMap, promise: Promise): Unit {
try {
Apptentive.register(getApplicationContext() , unpackCredentials(credentials))

// Register for lifecycle callbacks
val currentActivity = getActivityContext()
if (currentActivity == null) {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive instance was not initialized: current activity is null");
return;
}
val lifecycleCallbacks = ApptentiveActivityLifecycleCallbacks.getInstance()
lifecycleCallbacks.onActivityStarted(currentActivity)
lifecycleCallbacks.onActivityResumed(currentActivity)
lifecycleCallbacks.onActivityStopped(currentActivity)

Apptentive.addUnreadMessagesListener(this);
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to register Apptentive instance.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to register Apptentive instance.", e)
}
}

Expand All @@ -37,7 +52,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
promise.resolve(it)
}
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to engage event $event.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to engage event $event.", e)
}
}

Expand All @@ -49,7 +64,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
promise.resolve(it)
}
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to present Message Center.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to present Message Center.", e)
}
}

Expand All @@ -60,7 +75,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
Apptentive.setPersonName(name)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to set person name.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to set person name.", e)
}
}

Expand All @@ -70,7 +85,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
try {
promise.resolve(Apptentive.getPersonName() ?: "")
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to get person name.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to get person name.", e)
}
}

Expand All @@ -81,7 +96,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
Apptentive.setPersonEmail(email)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to set person email.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to set person email.", e)
}
}

Expand All @@ -91,7 +106,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
try {
promise.resolve(Apptentive.getPersonEmail() ?: "")
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to get person email.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to get person email.", e)
}
}

Expand Down Expand Up @@ -126,7 +141,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
Apptentive.removeCustomPersonData(key)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to remove custom person data $key.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to remove custom person data $key.", e)
}
}

Expand Down Expand Up @@ -161,7 +176,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
Apptentive.removeCustomDeviceData(key)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to remove custom device data $key.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to remove custom device data $key.", e)
}
}

Expand All @@ -173,7 +188,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
promise.resolve(it)
}
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to check if Apptentive interaction can be shown on event $event.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to check if Apptentive interaction can be shown on event $event.", e)
}
}

Expand All @@ -185,7 +200,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
promise.resolve(it)
}
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to check if Apptentive can launch Message Center.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to check if Apptentive can launch Message Center.", e)
}
}

Expand All @@ -195,7 +210,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
try {
promise.resolve(Apptentive.getUnreadMessageCount())
} catch (e: Exception) {
promise.reject("Apptentive Error", "Failed to check number of unread messages in Message Center.", e)
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to check number of unread messages in Message Center.", e)
}
}

Expand All @@ -211,7 +226,7 @@ class ApptentiveModule(reactContext: ReactApplicationContext) : ReactContextBase
"warn" -> ApptentiveLog.Level.WARN
"error" -> ApptentiveLog.Level.ERROR
else -> {
println("APPTENTIVE ERROR: Unknown log level $logLevel, setting to info by default.")
println("$APPTENTIVE_ERROR_CODE: Unknown log level $logLevel, setting to info by default.")
ApptentiveLog.Level.INFO
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="apptentive_distribution">React Native</string>
<string name="apptentive_distribution_version">6.0.0</string>
<string name="apptentive_distribution_version">6.0.1</string>
</resources>
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- apptentive-react-native (6.0.0):
- apptentive-react-native (6.0.1):
- ApptentiveKit (~> 6.0.2)
- React-Core
- ApptentiveKit (6.0.2)
Expand Down Expand Up @@ -344,7 +344,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
apptentive-react-native: 891019c93b93a3991cd0661d79967149b444ab31
apptentive-react-native: 638eacb7f645d64231d8f0c60dee7d3d0f9f6e9c
ApptentiveKit: a2190a8e7bf98639a7c117dbca3cc6004d6aaa64
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: cde416483dac037923206447da6e1454df403714
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apptentive-react-native",
"version": "6.0.0",
"version": "6.0.1",
"description": "React Native Module for Apptentive SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 50376ac

Please sign in to comment.