在React Native应用中发送应用邀请 [英] Sending App Invites in a React Native app
问题描述
在Facebook iOS SDK中,有一个名为应用程序邀请"的模块,允许将您的应用程序的邀请发送给您的朋友( https://developers.facebook.com/docs/ios/).
In the facebook iOS SDK, there is a module called App Invites, allowing to send invites to your app to your friends (https://developers.facebook.com/docs/ios/).
React Native应用程序似乎不存在此模块( https://developers.facebook. com/docs/react-native ),有人知道解决方法可以使其正常工作吗?
This module does not seem to exist for React Native apps (https://developers.facebook.com/docs/react-native) does anyone know a workaround to make it work?
非常感谢.
推荐答案
我实际上发现了如何在react-native-fbsdk中进行挖掘.
I actually found how to do it digging in react-native-fbsdk.
有一个名为AppInviteDialog的类,您可以像在此描述的ShareDialog一样使用: https: //developers.facebook.com/docs/react-native/sharing
There is a class called AppInviteDialog that you can use like the ShareDialog described here: 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);
}
);
}
...
});
发现愉快;)
这篇关于在React Native应用中发送应用邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!