alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
763 stars 398 forks source link

opens host app instead of share extension #30

Open fk1blow opened 7 years ago

fk1blow commented 7 years ago

I've got everything working on the simulator, but when trying to test it on a physical device(with no dev server whatsoever), instead of opening the share extension, it opens up the host application.

Before this, it didn't opened anything and then i remembered to add the https://github.com/alinz/react-native-share-extension#test-on-device-without-dev-server. Should this script be added to both host app and extension or just the extension?

currenty package.json:

"react-native": "0.42.3"
"react-native-share-extension": "^1.1.1"

Thanks in advance!

alinz commented 7 years ago

@fk1blow Both share and app should have the script. Also make sure to register you share component in JS as well. This described here

fk1blow commented 7 years ago

Both extension and host app are registered(and already where when i submitted this issue) and after your comment, i added the script to the host. Again, it does the same - it opens the host app instead of the extension.

Running this again on the simulator, after require-ing both share and host app(inside the index.ios.js), it starts to behave exactly like the physical device, opening the host app instead.

alinz commented 7 years ago

@fk1blow, One other thing, make sure the name of the component that you registered are currectly spelled in Objective-c code side of Share Extension. Double check the moduleName:@"MyShareEx" and replace MyShareEx with the one that you register inside index.ios.js


- (UIView*) shareView {
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"MyShareEx"
                                               initialProperties:nil
                                                   launchOptions:nil];
  rootView.backgroundColor = nil;
  return rootView;
}

if that one doesn't work then you have to make a sample project and send it to me so I can debug it for you.

fk1blow commented 7 years ago

both are the same, unfortunately! I will try to do it natively, because i'm running out of time!

Thanks!

alinz commented 7 years ago

Can you provide me a sample project? If you do I might be able to help you and get you going.