在React Native应用程序中发送应用程序邀请

Rap*_*buz 8 facebook react-native

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

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

非常感谢.

Rap*_*buz 16

我实际上发现了如何在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);
            }
        );
    }
    ...
});
Run Code Online (Sandbox Code Playgroud)

幸福的发现;)