@@ -370,6 +370,18 @@ public View getMerchantView(ViewGroup viewGroup, MerchantViewType merchantViewTy
370370 }
371371 }
372372
373+ private ReactInstanceManager getReactInstanceManagerFromHost (Object reactHost ) {
374+ if (reactHost == null ) {
375+ return null ;
376+ }
377+ try {
378+ Method getReactInstanceManagerMethod = reactHost .getClass ().getMethod ("getReactInstanceManager" );
379+ return (ReactInstanceManager ) getReactInstanceManagerMethod .invoke (reactHost );
380+ } catch (Exception e ) {
381+ return null ;
382+ }
383+ }
384+
373385 private void createHyperService (@ Nullable String tenantId , @ Nullable String clientId ) {
374386 FragmentActivity activity = (FragmentActivity ) getCurrentActivity ();
375387 if (activity == null ) {
@@ -381,11 +393,22 @@ private void createHyperService(@Nullable String tenantId, @Nullable String clie
381393 "activity is null" );
382394 return ;
383395 }
384- Application app = activity .getApplication ();
385- if (app instanceof ReactApplication ) {
386- this .app = ((ReactApplication ) app );
387- reactInstanceManager = ((ReactApplication ) app ).getReactNativeHost ().getReactInstanceManager ();
396+ Application application = activity .getApplication ();
397+ if (application instanceof ReactApplication ) {
398+ this .app = ((ReactApplication ) application );
399+ if (newArchEnabled ) {
400+ try {
401+ Method getReactHostMethod = app .getClass ().getMethod ("getReactHost" );
402+ Object reactHost = getReactHostMethod .invoke (app );
403+ reactInstanceManager = getReactInstanceManagerFromHost (reactHost );
404+ } catch (Exception e ) {
405+ reactInstanceManager = app .getReactNativeHost ().getReactInstanceManager ();
406+ }
407+ } else {
408+ reactInstanceManager = app .getReactNativeHost ().getReactInstanceManager ();
409+ }
388410 }
411+
389412 if (tenantId != null && clientId != null ) {
390413 hyperServices = new HyperServices (activity , tenantId , clientId );
391414 } else {
0 commit comments