React-native-navigation: Share Extension support

Created on 1 Apr 2017  ·  24Comments  ·  Source: wix/react-native-navigation

Is there a way to create a share extension on both platform using this extension ?

share extension example

I have already one share extension which is a bit... tricky and not at all viable. I used to call AppRegistery a second time for my extension but with this package, AppRegistry is not working anymore.

Android iOS

Most helpful comment

Any update on this?

All 24 comments

Hello I have the same problem and I possibly have dived a bit deeper into the problem.

I've opened an issue in the share extension repo that I assume Liroo is also using, there you can read more in detail how the two libs interact with eachother (at least according to my findings):

https://github.com/alinz/react-native-share-extension/issues/37

@kristoff-it @Liroo Hey guys, if one of you can upload an example app to github, I can also help debug the issue with you.

@guyca I made a sample project, you can find it here: https://github.com/kristoff-it/react-native-navigation-share-example

On iOS everything works as long as you use the debug compilation scheme, once you switch to release, iOS starts behaving like Android.
As you can read in alinz/react-native-share-extension#37, with [email protected] everything was still working.

As far as I can tell, Navigation kind of bypasses the AppRegistry API and this is what is causing trouble.

A (seemingly?) simple fix would be to be able to construct a check like:

if (mainAppIsBeingCalled){
   Navigation.startTabBasedApp...
} else {
  // don't call it
}

Thanks!

I was using a personal implementation of the share extension but it was such basic one and with RN updates, it doesn't work anymore. Btw I was intersted in a new one, I saw react-native-share-extension but I get the same problem :/

This issue is also related to the the fact that startApp is called each time the bundle is parsed. What op wants is not to call startApp, but instead invoke some method from a share library that accepts a registered component and displays it

Yes, please guys try to find a solution for this problem, I'm sure Liroo and me are not the only two who need support for share extensions.

Let me know if I can help with anything :)

@kristoff-it @Liroo I added Navigation.isAppLaunched method which allows you to check if the app is running or not, and call start*App only when needed. Note that this is relevant only to Android.

Thank you @guyca I will check it later, the share extension support is in 2 two weeks in my road map ;)

Any update on this?

+1 for any updates, going to be looking at adding this feature soon

Any update on Share Extension for v2? @guyca

I will look into it since our project switched from react-navigation to this. I will update you guys

update on this, I don't think It is possible to use this library in any extensions, the reason for that is react-native-navigation is tightly couple to UIApplication and AppDelegate in order to function. In ios extension has no access to UIApplication. I'm going to use react-navigation for now until someone in wix core can give us some apis for integrating with this type of scenario. :(

@guyca is there any way I can get access to UIView. I'm trying to find a way to use this library and any extensions. so far no success. As I said above, react-native-navigation is tightly coupled to UIApplication and based on my knowledge, none of the extensions have access to UIApplication.

Any thoughts on that?

any updates on this? cause in my case I made the extension work but in release mode it crashes with "name":"Invariant Violation","framesToPop":1 so far not sure what is causing the issue, what I do know is that I'm using AppRegistry.registerComponent to register the extension in JS code

Ok it seems that my problem on Android was that I had this in my MainApplication.java

@Override
  public String getJSMainModuleName() {
    return "index.android";
  }

But somehow on release mode is loading index.js instead of index.android.js

@guyca should this really be closed? This is quite clearly still an issue for some people but nobody from Wix has given a definitive answer about whether it's possible or not. You assigned @DanielZlotin in April last year and he hasn't commented...

I don't mean to sound rude or entitled about it but this is very easy to do natively yet doesn't seem possible with react-native-navigation. A lot of people using React Native want to use a native navigation library and this is quite an important feature for many apps.

Hey @MyGuySi
You're not rude, I closed all issues marked with the stale label yesterday. The reason the issue wasn't addressed is because we had no manpower to maintain v1. All team members from Wix involved in v1's development had other responsibilities and only recently we've allocated full time developers for this project - but only for v2.
Our goal is to have integration tests in v2 for popular libraries such as the share extension, but honestly we're a long way from there.

Meanwhile, if someone can confirm this is still an issue in v2, we'll reopen and address it.

@guyca I have developed the whole project in react native navigation v1 but I am not able to use share extension in this project by any mean. What should I do now?
Should I migrate to v2? Is it easy to migrate from v1 to v2?
Is there any trick to support share extension in v1 in both android and ios

I hope you will be able to help me.

@ahmedjamshed take a look at https://github.com/mattermost/mattermost-mobile we were able to implement a share extension

@guyca @alinz Is there a solution for react native navigation v1 OR do I need to upgrade to v2 OR the only solution is to switch to react navigation?

@ahmedjamshed take a look at https://github.com/mattermost/mattermost-mobile we were able to implement a share extension

Hi @enahum, I get the following error when try your solution...

AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.bmark/com.bfactory.share.ShareActivity}: java.lang.ClassCastException: com.bfactory.share.ShareActivity cannot be cast to com.reactnativenavigation.NavigationActivity

@mtzfactory which lib version do you use?

I have the same error on 2.27.9

Hi @DomIn3339, I'm using the same react-native-navigation as @enahum's app...

  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-navigation": "3.2.0"
  },
Was this page helpful?
0 / 5 - 0 ratings