|
15 | 15 | import com.facebook.react.bridge.ReadableArray; |
16 | 16 | import com.facebook.react.bridge.ReadableMap; |
17 | 17 | import com.facebook.react.bridge.UiThreadUtil; |
| 18 | +import com.facebook.react.bridge.WritableArray; |
18 | 19 | import com.facebook.react.bridge.WritableMap; |
19 | 20 | import com.facebook.react.modules.core.DeviceEventManagerModule; |
20 | 21 |
|
|
23 | 24 | import com.iterable.iterableapi.IterableAction; |
24 | 25 | import com.iterable.iterableapi.IterableActionContext; |
25 | 26 | import com.iterable.iterableapi.IterableApi; |
| 27 | +import com.iterable.iterableapi.IterableAttributionInfo; |
26 | 28 | import com.iterable.iterableapi.IterableAuthHandler; |
27 | 29 | import com.iterable.iterableapi.IterableAuthManager; |
28 | 30 | import com.iterable.iterableapi.IterableConfig; |
29 | 31 | import com.iterable.iterableapi.IterableCustomActionHandler; |
30 | | -import com.iterable.iterableapi.IterableAttributionInfo; |
| 32 | +import com.iterable.iterableapi.IterableEmbeddedMessage; |
31 | 33 | import com.iterable.iterableapi.IterableHelper; |
32 | 34 | import com.iterable.iterableapi.IterableInAppCloseAction; |
33 | 35 | import com.iterable.iterableapi.IterableInAppHandler; |
|
46 | 48 | import java.util.Map; |
47 | 49 | import java.util.HashMap; |
48 | 50 | import java.util.List; |
| 51 | +import java.util.ArrayList; |
49 | 52 | import java.util.concurrent.CountDownLatch; |
50 | 53 | import java.util.concurrent.TimeUnit; |
51 | 54 |
|
@@ -122,6 +125,7 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S |
122 | 125 | IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version); |
123 | 126 |
|
124 | 127 | IterableApi.getInstance().getInAppManager().addListener(this); |
| 128 | + IterableApi.getInstance().getEmbeddedManager().syncMessages(); |
125 | 129 |
|
126 | 130 | // MOB-10421: Figure out what the error cases are and handle them appropriately |
127 | 131 | // This is just here to match the TS types and let the JS thread know when we are done initializing |
@@ -185,6 +189,7 @@ public void initialize2WithApiKey(String apiKey, ReadableMap configReadableMap, |
185 | 189 | IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version); |
186 | 190 |
|
187 | 191 | IterableApi.getInstance().getInAppManager().addListener(this); |
| 192 | + IterableApi.getInstance().getEmbeddedManager().syncMessages(); |
188 | 193 |
|
189 | 194 | // MOB-10421: Figure out what the error cases are and handle them appropriately |
190 | 195 | // This is just here to match the TS types and let the JS thread know when we are done initializing |
@@ -683,14 +688,39 @@ public void sendEvent(@NonNull String eventName, @Nullable Object eventData) { |
683 | 688 | public void onInboxUpdated() { |
684 | 689 | sendEvent(EventName.receivedIterableInboxChanged.name(), null); |
685 | 690 | } |
| 691 | + // --------------------------------------------------------------------------------------- |
| 692 | + // endregion |
| 693 | + |
| 694 | + // --------------------------------------------------------------------------------------- |
| 695 | + // region Embedded messaging |
| 696 | + public void getEmbeddedPlacementIds(Promise promise) { |
| 697 | + IterableLogger.d(TAG, "getEmbeddedPlacementIds"); |
| 698 | + try { |
| 699 | + List<Long> placementIds = IterableApi.getInstance().getEmbeddedManager().getPlacementIds(); |
| 700 | + WritableArray writableArray = Arguments.createArray(); |
| 701 | + if (placementIds != null) { |
| 702 | + for (Long placementId : placementIds) { |
| 703 | + writableArray.pushDouble(placementId.doubleValue()); |
| 704 | + } |
| 705 | + } |
| 706 | + promise.resolve(writableArray); |
| 707 | + } catch (Exception e) { |
| 708 | + IterableLogger.e(TAG, "Error getting placement IDs: " + e.getLocalizedMessage()); |
| 709 | + promise.reject("", "Failed to get placement IDs: " + e.getLocalizedMessage()); |
| 710 | + } |
| 711 | + } |
| 712 | + |
| 713 | + // --------------------------------------------------------------------------------------- |
| 714 | + // endregion |
686 | 715 | } |
687 | 716 |
|
688 | 717 | enum EventName { |
689 | | - handleUrlCalled, |
690 | | - handleCustomActionCalled, |
691 | | - handleInAppCalled, |
692 | 718 | handleAuthCalled, |
693 | | - receivedIterableInboxChanged, |
| 719 | + handleAuthFailureCalled, |
694 | 720 | handleAuthSuccessCalled, |
695 | | - handleAuthFailureCalled |
| 721 | + handleCustomActionCalled, |
| 722 | + handleInAppCalled, |
| 723 | + handleUrlCalled, |
| 724 | + receivedIterableEmbeddedMessagesChanged, |
| 725 | + receivedIterableInboxChanged |
696 | 726 | } |
0 commit comments