2016-08-18 7 views
4

FacebookのiOS SDKには、App Invitesというモジュールがあり、あなたのアプリへの招待状を友人に送信できます(https://developers.facebook.com/docs/ios/)。Reactネイティブアプリでの招待の送信

このモジュールはReact Nativeアプリ(https://developers.facebook.com/docs/react-native)のために存在しないようですが、誰かがそれを動作させるための回避策を知っていますか?

多くのありがとうございます。

答えて

14

私は実際にreact-native-fbsdkでそれを掘る方法を発見しました。

あなたはShareDialogのように使用することができますAppInviteDialogと呼ばれるクラスがここにあります説明:https://developers.facebook.com/docs/react-native/sharing

const FBSDK = require('react-native-fbsdk'); 
const { 
    AppInviteDialog, 
} = FBSDK; 


module.exports = React.createClass({ 
    getInitialState: function() { 

     return { 
      appInviteContent: { 
      applinkUrl: 'https://yourapplink.com', 
      } 
     } 
    }, 

    shareLink: function() { 
     var tmp = this; 
     AppInviteDialog.canShow(this.state.appInviteContent).then(
      function(canShow) { 
       if (canShow) { 
        return AppInviteDialog.show(tmp.state.appInviteContent); 
       } 
      } 
     ).then(
      function(result) { 
       if (result.isCancelled) { 
        alert('Share operation was cancelled'); 
       } else { 
        alert('Share was successful with postId: ' + result.postId); 
       } 
      }, 
      function(error) { 
       alert('Share failed with error: ' + error); 
      } 
     ); 
    } 
    ... 
}); 

ハッピー発見;)

関連する問題