react-native-hubspot-wrapper 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  package com.marcinolek.reactnativehubspotwrapper
2
2
 
3
3
  import android.content.Intent
4
+ import android.webkit.CookieManager
4
5
  import com.facebook.react.bridge.Promise
5
6
  import com.facebook.react.bridge.ReactApplicationContext
6
7
  import com.facebook.react.bridge.ReadableArray
@@ -9,6 +10,8 @@ import com.hubspot.mobilesdk.HubspotWebActivity
9
10
  import kotlinx.coroutines.CoroutineScope
10
11
  import kotlinx.coroutines.Dispatchers
11
12
  import kotlinx.coroutines.launch
13
+ import kotlinx.coroutines.suspendCancellableCoroutine
14
+ import kotlin.coroutines.resume
12
15
 
13
16
  class HubspotWrapperModule(reactContext: ReactApplicationContext) :
14
17
  NativeHubspotWrapperSpec(reactContext) {
@@ -70,6 +73,7 @@ class HubspotWrapperModule(reactContext: ReactApplicationContext) :
70
73
  CoroutineScope(Dispatchers.Main).launch {
71
74
  try {
72
75
  hubspotManager.logout()
76
+ clearWebViewCookies()
73
77
  promise.resolve(null)
74
78
  } catch (error: Exception) {
75
79
  promise.reject("CLEAR_USER_DATA_ERROR", "Failed to clear HubSpot user data", error)
@@ -77,6 +81,16 @@ class HubspotWrapperModule(reactContext: ReactApplicationContext) :
77
81
  }
78
82
  }
79
83
 
84
+ private suspend fun clearWebViewCookies() {
85
+ suspendCancellableCoroutine<Unit> { continuation ->
86
+ val cookieManager = CookieManager.getInstance()
87
+ cookieManager.removeAllCookies {
88
+ cookieManager.flush()
89
+ continuation.resume(Unit)
90
+ }
91
+ }
92
+ }
93
+
80
94
  companion object {
81
95
  const val NAME = "NativeHubspotWrapper"
82
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hubspot-wrapper",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TurboModule wrapper for HubSpot mobile chat SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",