【问题标题】:Sending App Invites in a React Native app在 React Native 应用程序中发送应用程序邀请
【发布时间】:2016-08-18 18:39:45
【问题描述】:

在 facebook iOS SDK 中,有一个名为 App Invites 的模块,允许向您的朋友 (https://developers.facebook.com/docs/ios/) 发送应用邀请。

对于 React Native 应用程序 (https://developers.facebook.com/docs/react-native) 似乎不存在此模块,有人知道使其工作的解决方法吗?

非常感谢。

【问题讨论】:

    标签: facebook react-native


    【解决方案1】:

    我实际上发现了如何在 react-native-fbsdk 中进行挖掘。

    有一个名为 AppInviteDialog 的类,您可以像此处描述的 ShareDialog 一样使用它: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);
                }
            );
        }
        ...
    });
    

    快乐的发现 ;)

    【讨论】:

    • 这需要弹出。我们有什么办法不弹出?
    • 它不再工作了,请问有没有其他解决方案
    【解决方案2】:

    在我的情况下,我将使用共享对话框在 facebook 上共享...

    import { ShareDialog } from 'react-native-fbsdk';
    

    shareLinkWithShareDialog() {
      var tmp = this;
      ShareDialog.canShow(this.state.shareLinkContent).then(
        function(canShow) {
          if (canShow) {
            return ShareDialog.show(shareLinkContent = {
             contentType: 'link',
              contentUrl: "https://facebook.com",
      contentDescription: 'Facebook sharing is easy!',
    });
          }
        }
      ).then(
        function(result) {
          if (result.isCancelled) {
            alert('cancelled');
          } else {
            alert('successful with postId: '
              + result.postId);
          }
        },
        function(error) {
          alert('Exception : ' + error.message);
        }
      );
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-02
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      • 1970-01-01
      • 2016-11-06
      • 2018-04-25
      相关资源
      最近更新 更多