react-native-klarna-inapp-sdk 2.3.4 → 2.3.5
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.
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/payments/KlarnaPaymentViewManager.java +1 -1
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEventSender.java +4 -2
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java +3 -3
- package/package.json +1 -1
|
@@ -215,7 +215,7 @@ public class KlarnaPaymentViewManager extends RNKlarnaPaymentViewSpec<PaymentVie
|
|
|
215
215
|
private void postEventForView(String eventName, WritableMap additionalParams, PaymentViewWrapper wrapper) {
|
|
216
216
|
if (wrapper != null) {
|
|
217
217
|
KlarnaPaymentEvent event = new KlarnaPaymentEvent(wrapper.getId(), eventName, additionalParams);
|
|
218
|
-
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(
|
|
218
|
+
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactAppContext, wrapper.getId());
|
|
219
219
|
if (eventDispatcher != null) {
|
|
220
220
|
eventDispatcher.dispatchEvent(event);
|
|
221
221
|
}
|
|
@@ -40,9 +40,11 @@ public class KlarnaStandaloneWebViewEventSender {
|
|
|
40
40
|
private static final String PARAM_NAME_DID_CRASH = "didCrash";
|
|
41
41
|
|
|
42
42
|
private final Gson gson = new Gson();
|
|
43
|
+
private final WeakReference<ReactContext> reactContextWeakReference;
|
|
43
44
|
private final Map<WeakReference<KlarnaStandaloneWebView>, EventDispatcher> viewToDispatcher;
|
|
44
45
|
|
|
45
|
-
KlarnaStandaloneWebViewEventSender(@NonNull final Map<WeakReference<KlarnaStandaloneWebView>, EventDispatcher> viewToDispatcher) {
|
|
46
|
+
KlarnaStandaloneWebViewEventSender(@NonNull ReactContext reactContext, @NonNull final Map<WeakReference<KlarnaStandaloneWebView>, EventDispatcher> viewToDispatcher) {
|
|
47
|
+
this.reactContextWeakReference = new WeakReference<>(reactContext);
|
|
46
48
|
this.viewToDispatcher = viewToDispatcher;
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -110,7 +112,7 @@ public class KlarnaStandaloneWebViewEventSender {
|
|
|
110
112
|
private void postEventForView(KlarnaStandaloneWebViewEvent.Event event, WritableMap additionalParams, @Nullable KlarnaStandaloneWebView view) {
|
|
111
113
|
KlarnaStandaloneWebView klarnaStandaloneWebView = getKlarnaStandaloneWebView(view);
|
|
112
114
|
if (klarnaStandaloneWebView != null) {
|
|
113
|
-
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(
|
|
115
|
+
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContextWeakReference.get(), klarnaStandaloneWebView.getId());
|
|
114
116
|
if (eventDispatcher != null) {
|
|
115
117
|
KlarnaStandaloneWebViewEvent e = new KlarnaStandaloneWebViewEvent(klarnaStandaloneWebView.getId(), event.name, additionalParams);
|
|
116
118
|
eventDispatcher.dispatchEvent(e);
|
|
@@ -105,7 +105,7 @@ public class KlarnaStandaloneWebViewManager extends RNKlarnaStandaloneWebViewSpe
|
|
|
105
105
|
super();
|
|
106
106
|
this.reactAppContext = reactContext;
|
|
107
107
|
viewToDispatcher = new HashMap<>();
|
|
108
|
-
klarnaStandaloneWebViewEventSender = new KlarnaStandaloneWebViewEventSender(viewToDispatcher);
|
|
108
|
+
klarnaStandaloneWebViewEventSender = new KlarnaStandaloneWebViewEventSender(reactContext, viewToDispatcher);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
@ReactProp(name = "returnUrl")
|
|
@@ -224,7 +224,7 @@ public class KlarnaStandaloneWebViewManager extends RNKlarnaStandaloneWebViewSpe
|
|
|
224
224
|
@Override
|
|
225
225
|
protected KlarnaStandaloneWebView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
|
|
226
226
|
KlarnaStandaloneWebView klarnaStandaloneWebView = new KlarnaStandaloneWebView(
|
|
227
|
-
/* context */ reactAppContext,
|
|
227
|
+
/* context */ reactAppContext.getCurrentActivity(), // needs to be activity for SDK dialogs to work
|
|
228
228
|
/* attrs */ null,
|
|
229
229
|
/* defStyleAttr */ 0,
|
|
230
230
|
/* webViewClient */ klarnaStandaloneWebViewClient,
|
|
@@ -235,7 +235,7 @@ public class KlarnaStandaloneWebViewManager extends RNKlarnaStandaloneWebViewSpe
|
|
|
235
235
|
/* resourceEndpoint */ null,
|
|
236
236
|
/* returnURL */ null);
|
|
237
237
|
// Each view has its own event dispatcher.
|
|
238
|
-
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(
|
|
238
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactAppContext, klarnaStandaloneWebView.getId());
|
|
239
239
|
viewToDispatcher.put(new WeakReference<>(klarnaStandaloneWebView), dispatcher);
|
|
240
240
|
return klarnaStandaloneWebView;
|
|
241
241
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-klarna-inapp-sdk",
|
|
3
3
|
"title": "Klarna Mobile SDK React Native",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.5",
|
|
5
5
|
"description": "This library wraps Klarna Mobile SDK and exposes its functionality as React Native components.",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
7
7
|
"module": "lib/module/index",
|