@saltware/fidbek-react-native 0.1.1 → 0.1.2
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,5 +1,6 @@
|
|
|
1
1
|
package com.fidbek.reactnative
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import android.app.Application
|
|
4
5
|
import com.facebook.react.bridge.Promise
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -24,10 +25,18 @@ internal object FidbekBridge {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
Fidbek.initialize(application, token, shakeToOpenEnabled)
|
|
28
|
+
primeSdkActivityTracker(reactContext.currentActivity)
|
|
27
29
|
promise.resolve(null)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
fun open(promise: Promise) {
|
|
32
|
+
fun open(reactContext: ReactApplicationContext, promise: Promise) {
|
|
33
|
+
val currentActivity = reactContext.currentActivity
|
|
34
|
+
if (currentActivity == null) {
|
|
35
|
+
promise.reject("ERR_NO_CURRENT_ACTIVITY", "Current activity is unavailable")
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
primeSdkActivityTracker(currentActivity)
|
|
31
40
|
Fidbek.open()
|
|
32
41
|
promise.resolve(null)
|
|
33
42
|
}
|
|
@@ -36,4 +45,21 @@ internal object FidbekBridge {
|
|
|
36
45
|
Fidbek.shutdown()
|
|
37
46
|
promise.resolve(null)
|
|
38
47
|
}
|
|
48
|
+
|
|
49
|
+
private fun primeSdkActivityTracker(activity: Activity?) {
|
|
50
|
+
if (activity == null) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
val trackerField = Fidbek::class.java.getDeclaredField("activityTracker")
|
|
56
|
+
trackerField.isAccessible = true
|
|
57
|
+
val tracker = trackerField.get(null) ?: return
|
|
58
|
+
|
|
59
|
+
val onResumed = tracker.javaClass.getMethod("onActivityResumed", Activity::class.java)
|
|
60
|
+
onResumed.invoke(tracker, activity)
|
|
61
|
+
} catch (_: Throwable) {
|
|
62
|
+
// Best-effort priming only.
|
|
63
|
+
}
|
|
64
|
+
}
|
|
39
65
|
}
|
package/package.json
CHANGED