alinz / react-native-share-extension

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

Safari appears to freeze after trying to use share option #76

Open kevando opened 6 years ago

kevando commented 6 years ago

Great installation instructions. I think I followed them precisely and I get no response when I use the share icon in safari and nothing in the logs (even after uncommenting the debug line)

This is what happens: http://www.giphy.com/gifs/3o6fJgk6hzvRcamF4Q

If I am using pods, do I need to do anything extra to make that work?

TheTekton commented 6 years ago

Nothing of note in device log and console log both?

kevando commented 6 years ago

@TheTekton No, I added the OS_ENV enable setting to the scheme and uncommented the log level in the .m file. Pods don't mess anything up? Like I need to include that into the share extension target?

I will try to get the sample project working before I comment again here.

exentrich commented 6 years ago

Try my fork https://github.com/raindropio/react-native-share-extension It works for any app. I experienced many apps that not work with current version of this lib.

TheTekton commented 6 years ago

@kevando Any progress? If you get a sample going, I'll take a look. Pods shouldn't mess anything up. And you'd probably notice right away, if they were an issue, I think.

marknutter commented 6 years ago

@kevando I ran into this exact issue and was able to figure out a way around it. I had to run the main react native app from xcode, wait for it to launch in the simulator, and then go back to xcode and run the share extension app, choosing safari as the app it runs from when prompted, and waiting for safari to launch. From there, I was able to share from Safari and the modal popped up as expected.

sudeepagarwal24 commented 6 years ago

Getting RCTbridgeModule.h error using Detached from Expo Project In Demo Project Working Perfect .

guydu commented 6 years ago

Hey folks, I'm also stuck on the same issue.. any ideas?

AbdelhalimAhmed commented 6 years ago

any ideas guys it's very stuck ?!

tallen11 commented 6 years ago

Same deal here, anyone have any way whatsoever to get some sort of error message?

tallen11 commented 6 years ago

I've found that this issue arose after adding in the react-native-google-sign-in package. Is anyone else using this package and also having this issue?

BigPun86 commented 6 years ago

Facing the same issue when trying to share something from Safari or Image Gallery. "react": "^16.0.0-beta.5", "react-native": "0.53.3", "react-native-share-extension": "^1.2.1"

alizafardev commented 6 years ago

same issue react native 0.45

runjuu commented 6 years ago

same issue 😩 "react": "^16.3.2", "react-native": "^0.55.3", "react-native-share-extension": "^1.2.1"

runjuu commented 6 years ago

solve the problem

image
cdn34 commented 6 years ago

Doing AppRegistry.registerComponent('MyExt', () => ShareComponent) on a separate file seems to work for me. It's also needed to set the jsBundleURLForBundleRoot to the new file where the extension is now being registered instead of index. In my case the issue was with the Google SignIn module and doing this seems to fix it.

mtzfactory commented 6 years ago

I'm facing the same issue... No way to make it work... Any advance?

nakamotoo commented 5 years ago

same issue here......

nakamotoo commented 5 years ago

@cdn34 Separating files worked for me !!! Thanks !!!

cdn34 commented 5 years ago

@nakamotoo I ended up changing the solution I posted here due to issues building the app for production, you may face similar issues. In case you do, what I did to fix those was to update my index.js file to be the following :

import { AppRegistry } from "react-native";

AppRegistry.registerComponent('MyExt', () => require('./src/components/Share').default);
AppRegistry.registerComponent('App', () => require('./indexWrapper').default);

The contents of my original index.js file are now located in indexWrapper.js. This makes sure the extension only uses the modules it's actually requiring instead of the modules the main app is using.

nakamotoo commented 5 years ago

@cdn34 Thanks. I tried to build the app for production , and as you told me, Safari froze. Here are my index.js and ShareExtension.js. which I separated. index.js

import { AppRegistry } from "react-native";
import App from "./src/App";
import { name as appName } from "./app.json";

AppRegistry.registerComponent(appName, () => App);

ShareExtension.js

import { AppRegistry } from "react-native";
import Share from "./src/components/Share.ios";

AppRegistry.registerComponent("ShareExtension", () => Share);

I've tried your solution and fix my index.js like below but it didn't work...

import { AppRegistry } from "react-native";
import { name as appName } from "./app.json";

AppRegistry.registerComponent(
  "Share",
  () => require("./src/components/Share.ios").default
);
AppRegistry.registerComponent(appName, () => require("./src/App").default);

Could you please tell me how I should fix it ?

cdn34 commented 5 years ago

@nakamotoo In your project: Targets -> MyExt -> Build Phases -> Run Script - Add :

export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh

Also make sure to update the jsCodeLocation in MyExt.m to now point to your index file like so:

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

nakamotoo commented 5 years ago

@cdn34 Thanks for the reply, but actually I already have added the script. The problem is that by separating the index.js and ShareExtension.js, the extension only works in dev environment. After I fixed my index.js like above, the extension does not work even in dev environment. 2018-10-12 23 12 40 And my ShareExtension.m file is like this, it points to index file.

#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>

@interface ShareExtension : ReactNativeShareExtension
@end

@implementation ShareExtension

RCT_EXPORT_MODULE();

- (UIView*) shareView {
  NSURL *jsCodeLocation;

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

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

  // Uncomment for console output in Xcode console for release mode on device:
  RCTSetLogThreshold(RCTLogLevelInfo - 1);

  return rootView;
}

@end
cdn34 commented 5 years ago

@nakamotoo It's kind of hard to know what your current problem may be without any other information. I’ve also changed a lot things since then, so I don’t recall exactly if there were any other steps to fix the issue.

Other things I did at the time, not exactly sure if are related to your issue or not:


buildID=${PRODUCT_BUNDLE_IDENTIFIER}
extId="ext"

/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $buildID.$extId" "${SRCROOT}/${extId}/Info.plist"
Nanofortress commented 5 years ago

I also followed the tutorial for iOS (I only did the Setup iOS part), when I tried clicking on the share extension inside Safari, Safari froze and I see the following being printed on my Metro Bundler:

::1 - - [26/Nov/2018:22:57:30 +0000] "GET /index.bundle?platform=ios&dev=true&minify=false HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:57:35 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:57:39 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:00 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:05 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:09 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:13 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:17 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:21 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:25 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:29 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:33 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:37 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:22:58:41 +0000] "POST /symbolicate HTTP/1.1" 200 - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
...

It never stops printing the same line until I closed the Safari, and when I does it prints these:

::1 - - [26/Nov/2018:23:04:00 +0000] "POST /symbolicate HTTP/1.1" - - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:23:04:00 +0000] "POST /symbolicate HTTP/1.1" - - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:23:04:00 +0000] "POST /symbolicate HTTP/1.1" - - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"
::1 - - [26/Nov/2018:23:04:00 +0000] "POST /symbolicate HTTP/1.1" - - "-" "MyShareEx/1 CFNetwork/974.2.1 Darwin/18.0.0"

These only gets printed for 4 times.

vivek25constants commented 5 years ago

Has this issue been solved? I face the same issue