2016-05-05 11 views
4

私はreact-native-fbsdkパッケージを通じてReact NativeのFacebookに画像を共有しようとしています。react-native-fbsdkと画像を共有しますか?

私は次のことをドキュメントからほとんど完全にコピーしましたが、imageUrlをどのようにフォーマットするのか分かりません。SharingContent is invalidというエラーが出ています。

私はここで間違っていますか?

const sharePhotoContent = { 
    contentType: 'photo', 
    photos: [ 
    { 
     imageUrl: "./local/image/path.png", 
     userGenerated: false, 
     caption: "Hello World" 
    } 
    ] 
}; 

ShareDialog.canShow(sharePhotoContent).then(
    function(canShow) { 
    if (canShow) { 
     return ShareDialog.show(sharePhotoContent); 
    } 
    } 
).then(
    function(result) { 
    if (result.isCancelled) { 
     AlertIOS.alert('Share cancelled'); 
    } else { 
     AlertIOS.alert('Share success with postId: ' + result.postId); 
    } 
    }, 
    function(error) { 
    AlertIOS.alert('Share fail with error: ' + error); 
    } 
); 
+0

私はそれがしばらくしていることを知っていますが、これを行う方法を見つけたかどうかは疑問です。プロジェクトで.pngのURLを作成し、それをreact-native-fbsdk )?ありがとう – kwishnu

+0

いいえ、私はそれを把握したことはありません。 – nicholas

+0

Thnxが私に戻ってきたので、FacebookはRNが彼らの赤ちゃんであるため、これをもっと透明にすると思うだろう。ああよく – kwishnu

答えて

1

あなたは、画像のURIを取得し、それがSharePhotoContentの作成に使用するように反応するネイティブ・イメージピッカーhttps://github.com/marcshilling/react-native-image-pickerを使用することができます。

画像を共有するには、facebookアプリをインストールする必要があります。

+0

なぜ私のfbsdkでFacebookのログインボタンがクリックされないのですか? –

+0

@SusylGhimireこれについて新しいstackoverflow質問を開きますか? – dzhuowen

+0

はいなぜできません。 :) –

0
This is working fine for me 

    shareLinkWithShareDialog() { 

let shareLinkContent = { 

contentType: 'link', 

contentUrl: 'https://www.facebook.com/images/fb_icon_325x325.png', 

contentDescription: 'Facebook sharing is easy!' 
     } 

ShareDialog.canShow(shareLinkContent).then((canShow) => { 

if (canShow) return ShareDialog.show(shareLinkContent); 

} 

).then((result) => { 

if (result.isCancelled) { 

    alert('Share cancelled'); 

} else { 

    alert('Share success with postId: ' + result.postId); 

    } 

    }, 

    function(error) { 

    alert('Share fail with error: ' + error); 
     } 
    ); 
    } 
関連する問題