Reputation: 646
I installed the react-native-share package but I can't share directly to Twitter on IOS. It's working perfectly on Android.
I get this error:
{
"error": {
"code": "ECOM.RNSHARE1",
"domain": "com.rnshare",
"message": "The operation couldn’t be completed. Not installed",
"nativeStackIOS": [
"0 myApp 0x0000000102cd4ae0 RCTJSErrorFromCodeMessageAndNSError + 112",
"1 myApp 0x0000000102cd4a20 RCTJSErrorFromNSError + 256",
"2 myApp 0x0000000102c64f88 __41-[RCTModuleMethod processMethodSignature]_block_invoke_4.110 + 152",
"3 myApp 0x0000000102bb82cc -[GenericShare shareSingle:failureCallback:successCallback:serviceType:inAppBaseUrl:] + 2156",
"4 myApp 0x0000000102bbbb67 -[RNShare shareSingle:failureCallback:successCallback:] + 855",
"5 CoreFoundation 0x00000001119aa47c __invoking___ + 140",
"6 CoreFoundation 0x00000001119a7872 -[NSInvocation invoke] + 305",
"7 CoreFoundation 0x00000001119a7b05 -[NSInvocation invokeWithTarget:] + 70",
"8 myApp 0x0000000102c674e6 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2534",
"9 myApp 0x0000000102c6b97a _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1402",
"10 myApp 0x0000000102c6b22c _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 156",
"11 myApp 0x0000000102c6b189 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25",
"12 libdispatch.dylib 0x0000000114993876 _dispatch_call_block_and_release + 12",
"13 libdispatch.dylib 0x0000000114994a56 _dispatch_client_callout + 8",
"14 libdispatch.dylib 0x00000001149a1e20 _dispatch_main_queue_callback_4CF + 1073",
"15 CoreFoundation 0x000000011191185d __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9",
"16 CoreFoundation 0x000000011190c0ba __CFRunLoopRun + 2772",
"17 CoreFoundation 0x000000011190b103 CFRunLoopRunSpecific + 567",
"18 GraphicsServices 0x00000001156e1cd3 GSEventRunModal + 139",
"19 UIKitCore 0x0000000126758e63 -[UIApplication _run] + 928",
"20 UIKitCore 0x000000012675da53 UIApplicationMain + 101",
"21 myApp 0x00000001026dde38 main + 104",
"22 dyld 0x000000010de47e1e start_sim + 10",
"23 ??? 0x0000000205a0351e 0x0 + 8684320030",
"24 ??? 0x00000002059fe000 0x0 + 8684298240"
],
"userInfo": { "NSLocalizedFailureReason": "Not installed" }
}
}
I only got this error when I use the Share.shareSingle() function to share on Twitter, not when I use the Share.open().
My code:
const shareToTwitter = imageUri => {
let options = {
title: 'Share Title',
message: messageToShare,
url: imageUri,
social: Share.Social.TWITTER,
type: 'image/png',
};
Share.shareSingle(options)
.then(res => {
ignoreShare();
})
.catch(err => {
err && console.log('error in Share.open: ', err);
ignoreShare();
});
};
I guess it's a problem with iOS permissions and I already tried everything found here Github issue
And that is my info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Kryll.io</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) needs permission to save your screenshots on your device</string>
<key>UIAppFonts</key>
<array>
<string>Roboto-Black.ttf</string>
<string>Ionicons.ttf</string>
<string>AntDesign.ttf</string>
<string>Roboto-BlackItalic.ttf</string>
<string>Roboto-Bold.ttf</string>
<string>Roboto-BoldItalic.ttf</string>
<string>Roboto-Italic.ttf</string>
<string>Roboto-Light.ttf</string>
<string>Roboto-LightItalic.ttf</string>
<string>Roboto-Medium.ttf</string>
<string>Roboto-MediumItalic.ttf</string>
<string>Roboto-Regular.ttf</string>
<string>Roboto-Thin.ttf</string>
<string>Roboto-ThinItalic.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>viber</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbshareextension</string>
<string>instagram</string>
<string>instagram-stories</string>
<string>lineauth</string>
<string>line3rdp.com.zhiliaoapp.musically</string>
<string>whatsapp</string>
<string>fb-messenger-platform-20150714</string>
<string>fb-messenger-platform-20150305</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150128</string>
<string>snapchat</string>
<string>twitter</string>
<string>twitterauth</string>
<string>bandapp</string>
<string>kakaostory</string>
<string>navercafe</string>
<string>naverblog</string>
<string>vkauthorize</string>
<string>vk</string>
<string>vk-share</string>
<string>fb</string>
<string>fb-messenger-share-api</string>
<string>fb-messenger</string>
<string>comgooglemaps</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
The package is here and I installed it simply with:
npm i react-native-share --save
npx pod-install
Configuration:
"react": "17.0.2",
"react-native": "0.66.4",
"react-native-share": "^7.3.7",
Upvotes: 1
Views: 1190
Reputation: 646
So we found a workaround for the shareSingle with Twitter, by changing a little piece of code in GenericShare.m from the package:
Line 20:
From that:
if(![serviceType isEqualToString:@"com.apple.social.twitter"] && [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:inAppBaseUrl]]) {
To:
if([serviceType isEqualToString:@"com.apple.social.twitter"] && [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:inAppBaseUrl]]) {
Just remove the exclamation mark after the if.
This is probably a temporary fix, but it works for now.
Upvotes: 0