alinz / react-native-share-extension

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

works in simulator but not real device ios #111

Open pmella16 opened 6 years ago

pmella16 commented 6 years ago

hi, my app freeze in real device but not in simulator boths in ios iphone 5 -10.2

my code https://github.com/pmella16/share-extension

captura de pantalla 2018-08-07 a la s 20 49 57 captura de pantalla 2018-08-07 a la s 20 49 41

demo

https://www.youtube.com/watch?v=fZa1aXqmmX8

"dependencies": { "react": "16.4.1", "react-native": "0.56.0", "react-native-modalbox": "^1.6.0", "react-native-share-extension": "^1.2.1" }, "devDependencies": { "babel-jest": "23.4.2", "babel-preset-react-native": "^5", "jest": "23.4.2", "react-test-renderer": "16.4.1" },

please help !!

mtzfactory commented 6 years ago

I have the same problem...

arribbar commented 6 years ago

It was working fine for me until few days ago. I don't know why as I didn't change anything.

I got these logs now:

2018-08-30 14:34:52.974893+0200 KumbuShare[641:80950] TIC TCP Conn Failed [1:0x101224d00]: 1:61 Err(61)
2018-08-30 14:34:52.975080+0200 KumbuShare[641:80950] Task <F3E093E0-202A-47C6-97B8-394D925341BA>.<0> HTTP load failed (error code: -1004 [1:61])
2018-08-30 14:34:52.976245+0200 KumbuShare[641:80949] NSURLConnection finished with error - code -1004
2018-08-30 14:34:52.991 [info][tid:main][RCTCxxBridge.mm:213] Initializing <RCTCxxBridge: 0x10116dca0> (parent: <RCTBridge: 0x10116e1b0>, executor: (null))
2018-08-30 14:34:52.996624+0200 KumbuShare[641:80834] Initializing <RCTCxxBridge: 0x10116dca0> (parent: <RCTBridge: 0x10116e1b0>, executor: (null))
2018-08-30 14:34:53.068 [warn][tid:main][RCTBridge.m:121] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-08-30 14:34:53.067906+0200 KumbuShare[641:80834] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-08-30 14:34:53.104 [warn][tid:main][RCTModuleData.mm:69] Module ReactNativeShareExtension requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.104059+0200 KumbuShare[641:80834] Module ReactNativeShareExtension requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.104 [warn][tid:main][RCTModuleData.mm:69] Module KumbuShare requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.104458+0200 KumbuShare[641:80834] Module KumbuShare requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.107 [warn][tid:main][RCTModuleData.mm:69] Module RCTVideoManager requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.106847+0200 KumbuShare[641:80834] Module RCTVideoManager requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.107 [warn][tid:main][RCTModuleData.mm:69] Module RNFetchBlob requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.107260+0200 KumbuShare[641:80834] Module RNFetchBlob requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-30 14:34:53.146781+0200 KumbuShare[641:80950] [] nw_socket_connect connectx failed (fd 9, 127.0.0.1:8081 stream, pid: 641) [61: Connection refused]
2018-08-30 14:34:53.149402+0200 KumbuShare[641:80949] [] nw_connection_get_connected_socket 2 Connection has no connected handler
2018-08-30 14:34:53.149453+0200 KumbuShare[641:80949] TCP Conn 0x104bf1d30 Failed : error 0:61 [61]
2018-08-30 14:34:53.155 [fatal][tid:main] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2018-08-30 14:34:53.155690+0200 KumbuShare[641:80834] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
arribbar commented 5 years ago

Ok, I found the issue in my case. It was related to another rn lib I have added. I needed to add it manually to my share app. You might have more logs using your real device and your share app as scheme.

emadhajjar commented 5 years ago

@arribbar how did you find the solution?

arribbar commented 5 years ago

Eeeuh, searching ? 🤔 😁 Be sure you have in KumbuShare target, Build Phases, a Run Script section with

# Type a script or drag a script file from your workspace to insert its path.
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh

Well, you need more logs to know from which lib it comes from. For that purpose, 1 - select your share extension as scheme 2 - run it manually on real device 3 - you'll have all the logs to understand from which lib it comes from

Then, to add a lib, you have two options:

To add it manually, you need to

I hope it will be hopeful for you

LucM commented 5 years ago

If it can help someone. I fixed this problem changing the deployment target of the extension app from 12.1 to 9.0.

image

theone3nu commented 5 years ago

@LucM after i added your fix deployment target changed to 9.0 now i can see the extension in the safari browser. However when i select myextension app safari is freezed nothing is happening. Any help would be appreciated.

arribbar commented 5 years ago

@theone3nu, if you are on iOS, you can have logs from your extension by selecting its scheme in XCode to build it. It will probably help you in this case.

theone3nu commented 5 years ago

@arribbar Can you please tell me how to to select scheme and how to run that in the device. I directly run the parent application in the ios device. Where to check the logs.

arribbar commented 5 years ago

To do so, you need to:

theone3nu commented 5 years ago

@arribbar I have built my extension it asked me to choose an app i have chosen my parent app in the device. Then i have opened safari in the device selected share extension. Safari got freezed for some time and behaving normally after some time and am not able to see any logs in the xcode console. Its showing empty.

arribbar commented 5 years ago

Sorry @theone3nu, my solution is working for getting logs in your simulator. Just, Instead of choosing your parent app, choose safari and you'll have logs in XCode console.

In real device, use Console.app to get logs from your real device.

theone3nu commented 5 years ago

@arribar i am able to open that in safari. But how do i enable my react native app from photos gallery or whatsapp.

theone3nu commented 5 years ago

@arribbar Finally able to show my app in photos app by editing the info.plist. I have added NSExtensionActivationSupportsImageWithMaxCount in NSExtensionActivationRule. Now i am using await ShareExtension.openURL('myapp://'); in the share.ios.js component but it is not opening the myapp from photos app. Please help

arribbar commented 5 years ago

I have never used openURL function. I can only invite you to read this part of the readme, https://github.com/alinz/react-native-share-extension#open-container-app

And this is not anymore the same issue. If you have one using openUrl, please check issues and open a new one if needed

@pmella16, do you still have this issue ? Or can we close it ?

theone3nu commented 5 years ago

@arribbar I opened new issue. Can you please look into this and reply if you have any idea on that error https://github.com/alinz/react-native-share-extension/issues/126#issuecomment-441036207

theone3nu commented 5 years ago

Fixed all the issues @pmella16 You need to add build script``` export NODE_BINARY=node ../node_modules/react-native/scripts/react-native-xcode.sh



in the extension. Thanks for the great lib!
jvandenaardweg commented 5 years ago

If it can help someone. I fixed this problem changing the deployment target of the extension app from 12.1 to 9.0.

image

Thanks @LucM, this pointed me in the right direction. Figured out by building and trying that 10.0 (or lower) is the required version. Every Deployment Target higher then that makes the Share Extension not visible in Safari for me.

Also, below the iOS Target Properties I used for my Share (URL) extension, so it shows in; Safari, other browsers ánd other Apps that share a URL:

<key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionActivationRule</key>
            <dict>
                <key>NSExtensionActivationDictionaryVersion</key>
                <integer>2</integer>
                <key>NSExtensionActivationSupportsText</key>
                <true/>
                <key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
                <integer>1</integer>
                <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
                <integer>1</integer>
            </dict>
        </dict>
        <key>NSExtensionMainStoryboard</key>
        <string>MainInterface</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.share-services</string>
    </dict>

Also tried it without NSExtensionActivationSupportsText=true or NSExtensionActivationDictionaryVersion=2 but with the other rules still available, but then again this makes the Share Extension not show up in Safari.

So, the combination of NSExtensionActivationDictionaryVersion=2, NSExtensionActivationSupportsText=true, NSExtensionActivationSupportsWebPageWithMaxCount=1 and NSExtensionActivationSupportsWebURLWithMaxCount=1 seems required for sharing URL's.

It's a tricky one these settings and steps you need to take, but finally got it working!

SaraChicaD commented 5 years ago

We're using the library to share a link from an app, go to our app with that data, then go back to the original app. What was happening: when we went back to the app, it would be completely frozen. Just freeze, you couldn't tap on anything until you closed it and re-opened.

One of the errors we received:

2019-04-04 14:11:28.081890-0500 musx[400:116729] Task <2888927E-4C1F-4F9E-B85E-06142128D9EF>.<9> load failed with error Error Domain=NSPOSIXErrorDomain Code=53 "Software caused connection abort" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <2888927E-4C1F-4F9E-B85E-06142128D9EF>.<9>, _kCFStreamErrorDomainKey=1, NSErrorPeerAddressKey=<CFData 0x281de4690 [0x1cf2bd5f0]>{length = 16, capacity = 16, bytes = 0x100201bb22edfd990000000000000000}, _kCFStreamErrorCodeKey=53, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <2888927E-4C1F-4F9E-B85E-06142128D9EF>.<9>"
)} [53]

Which lead us to this we also had this error. Which lead us to the conclusion that it has something to do with the app trying to make requests in the background on iOS.

Relevant here is this part of that last link:

Background tasks can end in one of two ways:

When your app has finished doing whatever it set out to do.

When the system calls the task’s expiry handler.

Your code is responsible for calling endBackgroundTask(_:) in both cases.

Unfortunately we do not write Objective C, so we cannot implement this ourselves, but the way we fixed this was by not closing our app (the extension) until we come back to the originating app, after we finished the request in our app. This seemed to completely eliminate the freezing behavior.

Typing this up in case anyone can: 1.) add the relevant code to the library or 2.) has the same problem. Good luck!

JacobEdmondKerr commented 4 years ago

I was having a similar problem and this turned out to be the solution:

under the target build settings > code signing > code signing entitlements there were different files specifed for debug and release configurations

the debug (entitlements-debug.plist) one had the required entitlements set, but the release one (entitlements-release.plist) was empty!