react本机共享操作无法完成.未安装



我安装了react原生共享包,但无法在IOS上直接共享到Twitter。它在安卓系统上运行得很好。

我得到这个错误:

{
"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" }
}
}

我只是在Twitter上使用Share.shareSingle((函数进行共享时才出现这个错误,而不是在使用Share.open((.时

我的代码:

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();
});
};

我想这是iOS权限的问题,我已经尝试了在这里找到的所有Github问题

这就是我的信息列表:

<?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>

包在这里,我简单地安装了它:

npm i react-native-share --save
npx pod-install

配置:

"react": "17.0.2",
"react-native": "0.66.4",
"react-native-share": "^7.3.7",

因此,我们通过更改包中GenericShare.m中的一小段代码,找到了一个使用Twitter的shareSingle的解决方法:

第20行:

来自:

if(![serviceType isEqualToString:@"com.apple.social.twitter"] && [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:inAppBaseUrl]]) {

收件人:

if([serviceType isEqualToString:@"com.apple.social.twitter"] && [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:inAppBaseUrl]]) {

只需去掉if.后面的感叹号

这可能是一个临时的解决方案,但目前有效。

最新更新