react-native-share-extension: Share extension app can not run twice in one app(ios).

In IOS, the share extension cannot run twice, because it does not exit in the close method.

RCT_EXPORT_METHOD(close) {
    [extensionContext completeRequestReturningItems:nil
                                  completionHandler:nil];
}

What should i do if i wanna run it twice in one app? Would it be possible to append “exit(0);” to the method?

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 3
  • Comments: 24

Commits related to this issue

Most upvoted comments

Hi, I’m experiencing the same behaviour… at this moment only in the simulator. Any solution?

@AndrewHenderson @rbscott Thanks, your solution works for me, but I have my own approach.

  1. I’m using share bridge
  2. I call RNExitApp.exitApp() (from react-native-exit-app) right after call ShareExtension.close()

That solution works for me.

Be careful about using exit(0); in your code. It was causing the extension to close before the JavaScript code was run but only when the app was archived.