Skip to content

Commit

Permalink
Merge pull request #13 from CleverTap/develop
Browse files Browse the repository at this point in the history
[VC-473] Release Signed Call React Native SDK v0.0.5
  • Loading branch information
shivamsharma2710 authored Feb 8, 2024
2 parents 2c9fb2e + c7a8c70 commit 5b11959
Show file tree
Hide file tree
Showing 29 changed files with 5,443 additions and 647 deletions.
90 changes: 70 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,97 @@
# Change Log

### Version 0.0.5 (February 08, 2024 )

---

**What's new**

- **[Android Platform]**

- Supports [Signed Call Android SDK v0.0.5](https://repo1.maven.org/maven2/com/clevertap/android/clevertap-signedcall-sdk/0.0.5) which is compatible with [CleverTap Android SDK v5.2.2](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-522-december-22-2023).
- Introduces new properties `initiatorImage` and `receiverImage` in the `MissedCallActionClickResult` instance provided through the `SignedCall.addListener(SignedCall.SignedCallOnMissedCallActionClicked,(result:MissedCallActionClickResult) => {})` listener.
- Introduces a new public API: `SignedCallOnCallStatusListener.register(applicationContext)`. This API allows your application to receive VoIP call events through the `SignedCall.SignedCallOnCallStatusChanged` listener even when the app is in a killed state.

For detailed integration instructions, please refer to the documentation.

- **[iOS Platform]**
- Supports [Signed Call iOS SDK v0.0.6](https://github.com/CleverTap/clevertap-signedcall-ios-sdk/blob/main/CHANGELOG.md#version-006-january-19-2024) which is compatible with [CleverTap iOS SDK v5.2.2](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-522-november-21-2023).

**Breaking Changes**

- **[Android and iOS Platform]**
- The `SignedCall.SignedCallOnCallStatusChanged` listener will now provide an instance of the `CallEventResult` class instead of the `CallEvent` class. Please refer to the integration documentation for details on usage.
- **[iOS Platform]**
- iOS deployment target version is bumped to iOS 12.

**Behaviour Changes**

- **[Android Platform]**

- Handles UX issues during network loss or switch by invalidating the socket reconnection and establishing an active connection to process the call related actions.
- Modifies the SDK's behavior when the **Notifications Settings** are disabled for the application. Previously, if the app's notifications were disabled, the device rang on incoming calls without displaying the call screen in the background and killed states. In this version, the SDK now declines incoming calls when the notifications are disabled. If the notification settings are later enabled, the SDK resumes processing calls instead of automatically declining them.

- **[Android and iOS Platform]**
- The `SignedCall.addListener(SignedCall.SignedCallOnCallStatusChanged,(result:CallEventResult) => {})` listener will now provide updates in the call state to both the initiator and receiver of the call. Previously, it was exposed only to the initiator of the call.

**Bug Fixes**

- **[Android Platform]**

- Fixes multiple outgoing call requests initiated simultaneously through multiple calls of `SignedCall.call(receiverCuid, callContext, callProperties)`. The SDK now processes only one call at a time while rejecting other requests with a failure exception.
- Addresses an **IllegalStateException** which occurs while prompting the user with the poor/bad network conditions on the call-screen.

- **[Android and iOS Platform]**
- Addresses an infinite **Connecting** state issue on the call screen which was triggered by using CUIDs longer than 15 characters. In this version, the SDK extends support to CUIDs ranging from 5 to 50 characters.

### Version 0.0.4 (September 12, 2023)
-------------------------------------------

---

**What's new**

* **[Android Platform]**
* Supports [Signed Call Android SDK v0.0.4](https://repo1.maven.org/maven2/com/clevertap/android/clevertap-signedcall-sdk/0.0.4) which is compatible with [CleverTap Android SDK v5.2.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-520-august-10-2023).
- **[Android Platform]**

* **[iOS Platform]**
* Supports [Signed Call iOS SDK v0.0.5](https://github.com/CleverTap/clevertap-signedcall-ios-sdk/blob/main/CHANGELOG.md#version-005-aug-23-2023) which is compatible with [CleverTap iOS SDK v5.2.0](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-520-august-16-2023).
- Supports [Signed Call Android SDK v0.0.4](https://repo1.maven.org/maven2/com/clevertap/android/clevertap-signedcall-sdk/0.0.4) which is compatible with [CleverTap Android SDK v5.2.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-520-august-10-2023).

* **[Android and iOS Platform]**
* Adds support for hiding the **Powered by Signed Call** label from VoIP call screens. For more information, refer to [Override Dashboard Branding for Call Screen](https://developer.clevertap.com/docs/signed-call-react-native-sdk#overridedefaultbranding-all-platforms).
- **[iOS Platform]**

- Supports [Signed Call iOS SDK v0.0.5](https://github.com/CleverTap/clevertap-signedcall-ios-sdk/blob/main/CHANGELOG.md#version-005-aug-23-2023) which is compatible with [CleverTap iOS SDK v5.2.0](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-520-august-16-2023).

- **[Android and iOS Platform]**
- Adds support for hiding the **Powered by Signed Call** label from VoIP call screens. For more information, refer to [Override Dashboard Branding for Call Screen](https://developer.clevertap.com/docs/signed-call-react-native-sdk#overridedefaultbranding-all-platforms).

**Changes**

* **[Android Platform]**
* The **index.html** file used inside the SDK has been renamed to a unique name to prevent conflicts with the same file name that may exist in the application.
* Captures a missed call system event when a call initiator manually cancels the call, reported under the `SCEnd` system event.
* Adjust the Microphone permission prompt limit to align with the [permissible threshold](https://developer.android.com/about/versions/11/privacy/permissions#dialog-visibility) which is shown when the receiver attends the call. Previously, if the Microphone permission was denied even once, SDK would continue to block all incoming calls at the receiver's end. (***Note***: Starting from Android 11, users have the option to deny the prompt twice before the permission is blocked by system, whereas in earlier versions, users could deny the prompt until selecting the "don't ask again" checkbox.)
- **[Android Platform]**

- The **index.html** file used inside the SDK has been renamed to a unique name to prevent conflicts with the same file name that may exist in the application.
- Captures a missed call system event when a call initiator manually cancels the call, reported under the `SCEnd` system event.
- Adjust the Microphone permission prompt limit to align with the [permissible threshold](https://developer.android.com/about/versions/11/privacy/permissions#dialog-visibility) which is shown when the receiver attends the call. Previously, if the Microphone permission was denied even once, SDK would continue to block all incoming calls at the receiver's end. (**_Note_**: Starting from Android 11, users have the option to deny the prompt twice before the permission is blocked by system, whereas in earlier versions, users could deny the prompt until selecting the "don't ask again" checkbox.)

* **[Android and iOS Platform]**
* Captures a missed call system event when a call initiator manually cancels the call, reported under the `SCEnd` system event.
- **[Android and iOS Platform]**
- Captures a missed call system event when a call initiator manually cancels the call, reported under the `SCEnd` system event.

**Fixes**

* **[Android Platform]**
* Improved Bluetooth handling for a better user experience:
* Voice now goes through Bluetooth when Bluetooth connectivity is established during an ongoing call.
* Voice now goes through the internal speaker when Bluetooth connectivity is disabled from the call screen button.
* Resolved duplicate reporting of `SCIncoming` system events caused by receiving duplicate pushes for the same call, one from the socket and one from FCM.
- **[Android Platform]**
- Improved Bluetooth handling for a better user experience:
- Voice now goes through Bluetooth when Bluetooth connectivity is established during an ongoing call.
- Voice now goes through the internal speaker when Bluetooth connectivity is disabled from the call screen button.
- Resolved duplicate reporting of `SCIncoming` system events caused by receiving duplicate pushes for the same call, one from the socket and one from FCM.

## Version 0.0.2 (April 17, 2023)
-------------------------------------------

---

- Supports [Signed Call Android SDK v0.0.2](https://repo1.maven.org/maven2/com/clevertap/android/clevertap-signedcall-sdk/0.0.2) and [CleverTap Android SDK v4.7.5](https://github.com/CleverTap/clevertap-android-sdk/releases/tag/corev4.7.5_rmv1.0.3).
- Supports [Signed Call iOS SDK v0.0.2](https://github.com/CleverTap/clevertap-signedcall-ios-sdk/releases/tag/0.0.2) and [CleverTap iOS SDK v4.2.2](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/4.2.2)
- Supports Push Primer for [Android 13 notification runtime permission](https://developer.android.com/develop/ui/views/notifications/notification-permission).
- Adds new public API `disconnectSignallingSocket()` in order to close the Signalling socket connection.

## Version 0.0.1 (March 28, 2023)
-------------------------------------------

---

- Initial Release.
- Supports Signed Call Android SDK v0.0.1 and Signed Call iOS SDK v0.0.2.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
//Required dependencies for Signed Call Android SDK
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
compileOnly "com.clevertap.android:clevertap-android-sdk:5.2.0"
compileOnly "com.clevertap.android:clevertap-signedcall-sdk:0.0.4"
compileOnly "com.clevertap.android:clevertap-android-sdk:5.2.2"
compileOnly "com.clevertap.android:clevertap-signedcall-sdk:0.0.5"
compileOnly 'androidx.work:work-runtime:2.7.1'
compileOnly('io.socket:socket.io-client:2.1.0') {
exclude group: 'org.json', module: 'json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ package com.clevertap.rnsignedcallandroid

import android.annotation.SuppressLint
import com.clevertap.android.sdk.CleverTapAPI
import com.clevertap.android.signedcall.enums.VoIPCallStatus
import com.clevertap.android.signedcall.exception.CallException
import com.clevertap.android.signedcall.exception.InitException
import com.clevertap.android.signedcall.init.SignedCallAPI
import com.clevertap.android.signedcall.init.SignedCallInitConfiguration
import com.clevertap.android.signedcall.interfaces.OutgoingCallResponse
import com.clevertap.android.signedcall.interfaces.SignedCallInitResponse
import com.clevertap.android.signedcall.utils.SignedCallUtils
import com.clevertap.rnsignedcallandroid.internal.Events.ON_CALL_STATUS_CHANGED
import com.clevertap.rnsignedcallandroid.internal.Events.ON_MISSED_CALL_ACTION_CLICKED
import com.clevertap.rnsignedcallandroid.internal.events.EventEmitter
import com.clevertap.rnsignedcallandroid.internal.util.InitConfigSerializer.getInitConfigFromReadableMap
import com.clevertap.rnsignedcallandroid.internal.util.PayloadConverter.signedCallResponseToWritableMap
import com.clevertap.rnsignedcallandroid.internal.util.PayloadConverter.toSignedCallLogLevel
import com.clevertap.rnsignedcallandroid.internal.util.InitConfigSerializer.getInitConfigFromReadableMap
import com.clevertap.rnsignedcallandroid.internal.util.PayloadConverter.toWriteableMap
import com.clevertap.rnsignedcallandroid.internal.util.Utils.log
import com.clevertap.rnsignedcallandroid.internal.util.toJson
import com.facebook.react.bridge.*

class CleverTapSignedCallModule(private val reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
ReactContextBaseJavaModule(reactContext) {
private var mSignedCall: SignedCallAPI? = null
private var cleverTapAPI: CleverTapAPI? = null
private var eventEmitter: EventEmitter? = null

init {
eventEmitter = EventEmitter(reactContext)
cleverTapAPI = CleverTapAPI.getDefaultInstance(reactContext)
registerListeners(reactContext)
}

companion object {
Expand All @@ -36,8 +36,8 @@ class CleverTapSignedCallModule(private val reactContext: ReactApplicationContex
}

/**
* Exports the Name of the Android module.
* TypeScript/Javascript part of the package used this name to communicate with this NativeModule class.
* Exports the Name of the Android module. TypeScript/Javascript part of the package used this
* name to communicate with this NativeModule class.
*/
override fun getName(): String {
return NAME
Expand All @@ -53,13 +53,12 @@ class CleverTapSignedCallModule(private val reactContext: ReactApplicationContex
// Keep: Required for RN built in Event Emitter Calls.
}

/**
* Exports constants for Typescript or Javascript part of this package.
*/
override fun getConstants(): MutableMap<String, String> = hashMapOf(
ON_CALL_STATUS_CHANGED to ON_CALL_STATUS_CHANGED,
ON_MISSED_CALL_ACTION_CLICKED to ON_MISSED_CALL_ACTION_CLICKED
)
/** Exports constants for Typescript or Javascript part of this package. */
override fun getConstants(): MutableMap<String, String> =
hashMapOf(
ON_CALL_STATUS_CHANGED to ON_CALL_STATUS_CHANGED,
ON_MISSED_CALL_ACTION_CLICKED to ON_MISSED_CALL_ACTION_CLICKED
)

private fun getSignedCallAPI(): SignedCallAPI {
if (mSignedCall == null) {
Expand All @@ -68,14 +67,23 @@ class CleverTapSignedCallModule(private val reactContext: ReactApplicationContex
return mSignedCall!!
}

@SuppressLint("RestrictedApi")
private fun registerListeners(context: ReactContext) {
if (!SignedCallUtils.isAppInBackground()) {
SignedCallAPI.getInstance().registerVoIPCallStatusListener { data ->
log(message = "SignedCallOnCallStatusListener is invoked in foreground or background: $data")
EventEmitter.emit(context, ON_CALL_STATUS_CHANGED, data.toWriteableMap())
}
}
}

@SuppressLint("RestrictedApi")
@ReactMethod
fun trackSdkVersion(sdkName: String, sdkVersion: Int) {
cleverTapAPI?.let {
cleverTapAPI!!.setCustomSdkVersion(sdkName, sdkVersion)
} ?: run {
log(message = "$ERROR_CLEVERTAP_INSTANCE_NOT_INITIALIZED to track the SDK Version");
}
cleverTapAPI?.let { cleverTapAPI!!.setCustomSdkVersion(sdkName, sdkVersion) }
?: run {
log(message = "$ERROR_CLEVERTAP_INSTANCE_NOT_INITIALIZED to track the SDK Version")
}
}

@ReactMethod
Expand All @@ -92,18 +100,20 @@ class CleverTapSignedCallModule(private val reactContext: ReactApplicationContex
initProperties?.let {
try {
val initConfiguration: SignedCallInitConfiguration? = getInitConfigFromReadableMap(it)
signedCallAPI.init(reactContext,
initConfiguration,
cleverTapAPI,
object : SignedCallInitResponse {
override fun onSuccess() {
promise.resolve(signedCallResponseToWritableMap(exception = null))
}

override fun onFailure(initException: InitException) {
promise.resolve(signedCallResponseToWritableMap(initException))
signedCallAPI.init(
reactContext,
initConfiguration,
cleverTapAPI,
object : SignedCallInitResponse {
override fun onSuccess() {
promise.resolve(signedCallResponseToWritableMap(exception = null))
}

override fun onFailure(initException: InitException) {
promise.resolve(signedCallResponseToWritableMap(initException))
}
}
})
)
} catch (throwable: Throwable) {
val errorMessage = "Exception while initializing the Signed Call native module"
log(message = errorMessage + ": " + throwable.localizedMessage)
Expand All @@ -112,78 +122,54 @@ class CleverTapSignedCallModule(private val reactContext: ReactApplicationContex
}
}

/**
* Sends the call-details to initiate a VoIP call
*/
/** Sends the call-details to initiate a VoIP call */
@ReactMethod
fun call(
receiverCuid: String, callContext: String, callProperties: ReadableMap?, promise: Promise
receiverCuid: String,
callContext: String,
callProperties: ReadableMap?,
promise: Promise
) {
val signedCallAPI: SignedCallAPI = getSignedCallAPI()
try {
val callOptions = callProperties?.toJson()
signedCallAPI.call(
reactContext,
receiverCuid,
callContext,
callOptions,
object : OutgoingCallResponse {
override fun callStatus(callStatus: VoIPCallStatus) {
emitCallEvent(callStatus)
}

override fun onSuccess() {
promise.resolve(signedCallResponseToWritableMap(exception = null))
}
reactContext,
receiverCuid,
callContext,
callOptions,
object : OutgoingCallResponse {
override fun onSuccess() {
promise.resolve(signedCallResponseToWritableMap(exception = null))
}

override fun onFailure(callException: CallException?) {
promise.resolve(signedCallResponseToWritableMap(callException))
override fun onFailure(callException: CallException?) {
promise.resolve(signedCallResponseToWritableMap(callException))
}
}
})
)
} catch (throwable: Throwable) {
val errorMessage = "Exception while initiating the VoIP Call"
log(message = errorMessage + ": " + throwable.localizedMessage)
promise.reject(errorMessage, throwable)
}
}

/**
* Logs out the Signed Call SDK session
*/
/** Logs out the Signed Call SDK session */
@ReactMethod
fun logout() {
getSignedCallAPI().logout(reactContext)
}

/**
* Ends the active call, if any.
*/
/** Ends the active call, if any. */
@ReactMethod
fun hangupCall() {
getSignedCallAPI().callController?.endCall()
}

/**
* Disconnects the signalling socket
*/
/** Disconnects the signalling socket */
@ReactMethod
fun disconnectSignallingSocket() {
getSignedCallAPI().disconnectSignallingSocket(reactContext)
}

/**
* Sends the real-time changes in the call-state to an observable event-stream
*/
private fun emitCallEvent(callStatus: VoIPCallStatus) {
val callEventName = when (callStatus) {
VoIPCallStatus.CALL_CANCELLED -> "Cancelled"
VoIPCallStatus.CALL_DECLINED -> "Declined"
VoIPCallStatus.CALL_MISSED -> "Missed"
VoIPCallStatus.CALL_ANSWERED -> "Answered"
VoIPCallStatus.CALL_IN_PROGRESS -> "CallInProgress"
VoIPCallStatus.CALL_OVER -> "Ended"
VoIPCallStatus.CALLEE_BUSY_ON_ANOTHER_CALL -> "ReceiverBusyOnAnotherCall"
}
eventEmitter?.emit(ON_CALL_STATUS_CHANGED, callEventName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.clevertap.rnsignedcallandroid

import android.content.Context
import com.clevertap.android.signedcall.init.SignedCallAPI
import com.clevertap.rnsignedcallandroid.internal.Events
import com.clevertap.rnsignedcallandroid.internal.events.EventEmitter
import com.clevertap.rnsignedcallandroid.internal.util.PayloadConverter.toWriteableMap
import com.clevertap.rnsignedcallandroid.internal.util.Utils.log

open class SignedCallOnCallStatusListener {

companion object {

@JvmStatic
fun register(context: Context) {
log(message = "SignedCallOnCallStatusListener is registered!")

SignedCallAPI.getInstance().registerVoIPCallStatusListener { data ->
log(message = "SignedCallOnCallStatusListener is invoked in killed state: $data")
EventEmitter.emit(context, Events.ON_CALL_STATUS_CHANGED, data.toWriteableMap())
}
}
}
}
Loading

0 comments on commit 5b11959

Please sign in to comment.