onNewIntent() is not called on ReactContextBaseJavaModule (react-native)

前端 未结 2 335
太阳男子
太阳男子 2021-01-14 21:21

I\'m building a react native module, from my module I send a PendingIntent like this.

Intent postAuthorizationIntent = new Intent(\"com.example.HANDLE_AUTHOR         


        
相关标签:
2条回答
  • 2021-01-14 21:56

    I had this same issue and fixed it by calling super.onNewIntent(intent) from MainActivity:

    @Override
    public void onNewIntent(Intent intent) {
        setIntent(intent);
        super.onNewIntent(intent);
    }
    

    With this in place, onNewIntent is called in your module - assuming your module implements ActivityEventListener and you've registered it as a listener in the constructor:

    reactContext.addActivityEventListener(this);
    
    0 讨论(0)
  • 2021-01-14 22:16

    Ok I solved the issue.

    public class RNSsfAuthModule extends ReactContextBaseJavaModule implements ActivityEventListener, Application.ActivityLifecycleCallbacks{
        ....
    
        public ExampleModule(ReactApplicationContext reactContext, Application application) {
                super(reactContext);
                ...
                reactContext.addActivityEventListener(this);
                application.registerActivityLifecycleCallbacks(this);
              }
    
        ...
    
    
        @Override
        public void onActivityStarted(Activity activity) {
            checkIntent(activity.getIntent());
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题