@@ -69,6 +69,8 @@ public class RNIterableAPIModuleImpl implements IterableUrlHandler, IterableCust
6969
7070 private final InboxSessionManager sessionManager = new InboxSessionManager ();
7171
72+ private boolean pushOpenHandlerPresent = false ;
73+
7274 public RNIterableAPIModuleImpl (ReactApplicationContext reactContext ) {
7375 this .reactContext = reactContext ;
7476 }
@@ -93,6 +95,8 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S
9395 configBuilder .setAuthHandler (this );
9496 }
9597
98+ pushOpenHandlerPresent = configReadableMap .hasKey ("pushOpenHandlerPresent" ) && configReadableMap .getBoolean ("pushOpenHandlerPresent" );
99+
96100 // Check if embedded messaging is enabled before building config
97101 boolean enableEmbeddedMessaging = configReadableMap .hasKey ("enableEmbeddedMessaging" ) && configReadableMap .getBoolean ("enableEmbeddedMessaging" );
98102
@@ -136,6 +140,9 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S
136140 IterableApi .getInstance ().getEmbeddedManager ().addUpdateListener (this );
137141 }
138142
143+ // Emit push open event for cold-start push opens
144+ emitPushOpenIfPresent ();
145+
139146 // MOB-10421: Figure out what the error cases are and handle them appropriately
140147 // This is just here to match the TS types and let the JS thread know when we are done initializing
141148 promise .resolve (true );
@@ -161,6 +168,8 @@ public void initialize2WithApiKey(String apiKey, ReadableMap configReadableMap,
161168 configBuilder .setAuthHandler (this );
162169 }
163170
171+ pushOpenHandlerPresent = configReadableMap .hasKey ("pushOpenHandlerPresent" ) && configReadableMap .getBoolean ("pushOpenHandlerPresent" );
172+
164173 // NOTE: There does not seem to be a way to set the API endpoint
165174 // override in the Android SDK. Check with @Ayyanchira and @evantk91 to
166175 // see what the best approach is.
@@ -208,6 +217,9 @@ public void initialize2WithApiKey(String apiKey, ReadableMap configReadableMap,
208217 IterableApi .getInstance ().getEmbeddedManager ().addUpdateListener (this );
209218 }
210219
220+ // Emit push open event for cold-start push opens
221+ emitPushOpenIfPresent ();
222+
211223 // MOB-10421: Figure out what the error cases are and handle them appropriately
212224 // This is just here to match the TS types and let the JS thread know when we are done initializing
213225 promise .resolve (true );
@@ -596,6 +608,12 @@ public boolean handleIterableCustomAction(@NonNull IterableAction action, @NonNu
596608 } catch (JSONException e ) {
597609 IterableLogger .e (TAG , "Failed handling custom action" );
598610 }
611+
612+ // Also emit push open event when the custom action originated from a push notification
613+ if (pushOpenHandlerPresent && actionContext .source .ordinal () == 0 /* PUSH */ ) {
614+ emitPushOpenIfPresent ();
615+ }
616+
599617 // The Android SDK will not bring the app into focus is this is `true`. It still respects the `openApp` bool flag.
600618 return false ;
601619 }
@@ -635,6 +653,12 @@ public boolean handleIterableURL(@NonNull Uri uri, @NonNull IterableActionContex
635653 } catch (JSONException e ) {
636654 IterableLogger .e (TAG , e .getLocalizedMessage ());
637655 }
656+
657+ // Also emit push open event when the URL action originated from a push notification
658+ if (pushOpenHandlerPresent && actionContext .source .ordinal () == 0 /* PUSH */ ) {
659+ emitPushOpenIfPresent ();
660+ }
661+
638662 return true ;
639663 }
640664
@@ -701,6 +725,18 @@ public void sendEvent(@NonNull String eventName, @Nullable Object eventData) {
701725 reactContext .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class ).emit (eventName , eventData );
702726 }
703727
728+ private void emitPushOpenIfPresent () {
729+ if (!pushOpenHandlerPresent ) {
730+ return ;
731+ }
732+ Bundle payloadData = IterableApi .getInstance ().getPayloadData ();
733+ if (payloadData != null ) {
734+ WritableMap eventData = Arguments .createMap ();
735+ eventData .putMap ("pushPayload" , Arguments .fromBundle (payloadData ));
736+ sendEvent (EventName .handlePushOpenCalled .name (), eventData );
737+ }
738+ }
739+
704740 @ Override
705741 public void onInboxUpdated () {
706742 sendEvent (EventName .receivedIterableInboxChanged .name (), null );
@@ -809,6 +845,7 @@ enum EventName {
809845 handleEmbeddedMessageUpdateCalled ,
810846 handleEmbeddedMessagingDisabledCalled ,
811847 handleInAppCalled ,
848+ handlePushOpenCalled ,
812849 handleUrlCalled ,
813850 receivedIterableEmbeddedMessagesChanged ,
814851 receivedIterableInboxChanged
0 commit comments