Skip to content

Commit

Permalink
Release 6.1.3 (#242)
Browse files Browse the repository at this point in the history
Release 6.1.3
  • Loading branch information
ChaseApptentive authored Aug 3, 2023
1 parent 1d7f8a2 commit d8e60a8
Show file tree
Hide file tree
Showing 9 changed files with 4,780 additions and 5,018 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ This document lets you know what has changed in the React Native module. For cha
- [Android Changelog](https://github.com/apptentive/apptentive-kit-android/blob/master/CHANGELOG.md)
- [iOS Changelog](https://github.com/apptentive/apptentive-kit-ios/blob/main/CHANGELOG.md)

# 2023-08-02 - v6.1.3

- Apptentive Android SDK: 6.1.0
- Apptentive iOS SDK: 6.2.2

# 2023-04-26 - v6.1.2

- Apptentive Android SDK: 6.0.4
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

// Apptentive
implementation 'com.apptentive:apptentive-kit-android:6.0.4'
implementation 'com.apptentive:apptentive-kit-android:6.1.0'
}

if (isNewArchitectureEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import apptentive.com.android.feedback.ApptentiveActivityInfo
import apptentive.com.android.feedback.ApptentiveConfiguration
import apptentive.com.android.feedback.EngagementResult
import apptentive.com.android.feedback.RegisterResult
import apptentive.com.android.feedback.model.MessageCenterNotification
import apptentive.com.android.util.InternalUseOnly
import apptentive.com.android.util.Log
import apptentive.com.android.util.LogLevel
Expand Down Expand Up @@ -67,198 +68,212 @@ class ApptentiveModule(private val reactContext: ReactApplicationContext) :
Apptentive.registerApptentiveActivityInfoCallback(this)

Log.d(REACT_NATIVE_TAG, "Observing Message Center Notification")
Apptentive.messageCenterNotificationObservable.observe { notification ->
Log.v(REACT_NATIVE_TAG, "Message Center notification received: $notification")
val eventEmitter =
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
val map = WritableNativeMap()
map.putInt("count", notification?.unreadMessageCount ?: 0)

eventEmitter.emit(UNREAD_MESSAGE_COUNT_CHANGED, map)
}
Apptentive.messageCenterNotificationObservable.observe(::observeNewMessage)

Log.d(REACT_NATIVE_TAG, "Register lifecycle observe")
reactApplicationContext.addLifecycleEventListener(this)
}

// Handle new message center notification
private fun observeNewMessage(notification: MessageCenterNotification?) {
Log.v(REACT_NATIVE_TAG, "Message Center notification received: $notification")

val map = WritableNativeMap()
map.putInt("count", notification?.unreadMessageCount ?: 0)

val eventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
eventEmitter.emit(UNREAD_MESSAGE_COUNT_CHANGED, map)
}

// Engage an event by an event name string
@ReactMethod
fun engage(event: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.engage(event) {
promise.resolve(it is EngagementResult.InteractionShown)
}
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to engage event $event.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Show the Apptentive Message Center
@ReactMethod
fun showMessageCenter(promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.showMessageCenter {
promise.resolve(it is EngagementResult.InteractionShown)
}
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to present Message Center.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Set person name
@ReactMethod
fun setPersonName(name: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.setPersonName(name)
promise.resolve(true)
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to set person name.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Get person name, empty string if there is none
@ReactMethod
fun getPersonName(promise: Promise) {
try {
if (isApptentiveRegistered) {
promise.resolve(Apptentive.getPersonName().orEmpty())
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to get person name.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Set person email
@ReactMethod
fun setPersonEmail(email: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.setPersonEmail(email)
promise.resolve(true)
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to set person email.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Get person email, empty string if there is none
@ReactMethod
fun getPersonEmail(promise: Promise) {
try {
if (isApptentiveRegistered) {
promise.resolve(Apptentive.getPersonEmail().orEmpty())
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to get person email.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add person custom data based on key string and value of type bool
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomPersonDataBoolean(key: String, value: Boolean, promise: Promise) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add person custom data based on key string and value of type double
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomPersonDataNumber(key: String, value: Double, promise: Promise) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add person custom data based on key string and value of type String
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomPersonDataString(key: String, value: String, promise: Promise) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomPersonData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Remove person custom data based on key string
@ReactMethod
fun removeCustomPersonData(key: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.removeCustomPersonData(key)
promise.resolve(true)
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to remove custom person data $key.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add device custom data based on key string and value of type bool
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomDeviceDataBoolean(key: String, value: Boolean, promise: Promise) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add device custom data based on key string and value of type double
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomDeviceDataNumber(key: String, value: Double, promise: Promise) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Add device custom data based on key string and value of type string
// Delegated from addCustomPersonData(key, value)
@ReactMethod
fun addCustomDeviceDataString(key: String, value: String, promise: Promise) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
if (isApptentiveRegistered) {
Apptentive.addCustomDeviceData(key, value)
promise.resolve(true)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Remove device custom data based on key string
@ReactMethod
fun removeCustomDeviceData(key: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
Apptentive.removeCustomDeviceData(key)
promise.resolve(true)
} catch (e: Exception) {
promise.reject(APPTENTIVE_ERROR_CODE, "Failed to remove custom device data $key.", e)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Check if an event name will launch an interaction
@ReactMethod
fun canShowInteraction(event: String, promise: Promise) {
try {
if (isApptentiveRegistered) {
val canShow = Apptentive.canShowInteraction(event)
promise.resolve(canShow)
} catch (e: Exception) {
promise.reject(
APPTENTIVE_ERROR_CODE,
"Failed to check if Apptentive interaction can be shown on event $event.",
e
)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Check if Message Center can be shown
@ReactMethod
fun canShowMessageCenter(promise: Promise) {
try {
if (isApptentiveRegistered) {
val canShow = Apptentive.canShowMessageCenter()
promise.resolve(canShow)
} catch (e: Exception) {
promise.reject(
APPTENTIVE_ERROR_CODE,
"Failed to check if Apptentive can launch Message Center.",
e
)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

// Get unread message count in Message Center
@ReactMethod
fun getUnreadMessageCount(promise: Promise) {
try {
if (isApptentiveRegistered) {
val count = Apptentive.getUnreadMessageCount()
promise.resolve(count)
} catch (e: Exception) {
promise.reject(
APPTENTIVE_ERROR_CODE,
"Failed to check number of unread messages in Message Center.",
e
)
} else {
promise.reject(APPTENTIVE_ERROR_CODE, "Apptentive is not registered.")
}
}

Expand Down Expand Up @@ -337,9 +352,8 @@ class ApptentiveModule(private val reactContext: ReactApplicationContext) :
return currentActivity?.applicationContext as Application?
}

override fun getApptentiveActivityInfo(): Activity {
return (currentActivity as? AppCompatActivity)
?: throw IllegalStateException("Activity $this could not retrieve currentActivity from React Native.")
override fun getApptentiveActivityInfo(): Activity? {
return currentActivity
}

override fun hasConstants(): Boolean {
Expand All @@ -359,5 +373,7 @@ class ApptentiveModule(private val reactContext: ReactApplicationContext) :

override fun onHostPause() {}

override fun onHostDestroy() {}
override fun onHostDestroy() {
Apptentive.messageCenterNotificationObservable.removeObserver(::observeNewMessage)
}
}
2 changes: 2 additions & 0 deletions example/ios/ApptentiveExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand Down Expand Up @@ -518,6 +519,7 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand Down
Loading

0 comments on commit d8e60a8

Please sign in to comment.