Search code examples
androidiosreact-nativeintentfiltershare-extension

Get the shared text from other apps in React Native


I want to get the shared text from other apps, I refer to this article, use intent-filter but it is not so smooth, I found that I need to get the intent from onCreate or onNewIntent to process, but the problem is that createReactActivityDelegate and getLaunchOptions always take precedence Execution, I can't get the intent and then pass it to React Native. Am I missing something? Or is there another way to replace the intent-filter, and I plan to use the share extension for iOS. Is this suitable for react native? Thanks in advance.

Q:

  1. createReactActivityDelegate and getLaunchOptions always execute before onCreate and onNewIntent, so I can not send the intent to React Native.
  2. I plan to use the share extension for iOS. Is this suitable for react native?
  3. Is there another way to replace the intent-filter and share extension?

Solution

  • Update my solution.

    1. I send the event to JavaScript when I got the shared text, but be aware of the life cycle of NativeModules.
    2. It is my first time using share extension and it working fine.
    3. I didn't specifically look for other alternatives.

    I hope this information can help you who has the same question.