FB App邀请Xamarin [英] FB App Invites with Xamarin

查看:79
本文介绍了FB App邀请Xamarin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究如何实现Facebook邀请对话框,并注意到Facebook现在提供了一个新的 FB App Invite 产品.有没有办法在Xamarin iOS上使用新的App Invite产品?

I am looking at how to implement a Facebook invite dialog and noticed that Facebook now offers a new FB App Invite product. Is there a way to use the new App Invite product with Xamarin iOS?

谢谢!

推荐答案

这是应用邀请的实现

您需要为Appinvites创建本机实现

只需创建一个名为IFacebookService的接口

Just create one interface called IFacebookService

如示例所示定义方法定义

Define Method defination as shown in example

public interface IFacebookservice{
  InviteFriends (string appLinkURL, string previewImageURL);
}

并在平台端进行该实现,如下所示

and do that implementation on platform side as shown in below

IOS FacebookService.CS

public void InviteFriends (string appLinkURL, string previewImageURL)
{
            var fromController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            var content = new AppInviteContent {
                AppLinkURL = new NSUrl (appLinkURL),
                PreviewImageURL = new NSUrl (previewImageURL)
            };
            AppInviteDialog.Show (fromController, content, null);
}

Android FacebookService.Cs

  public void InviteFriends(string appLinkURL, string previewImageURL)
    {
        if (AppInviteDialog.CanShow())
        {
            var activity = Xamarin.Forms.Forms.Context as Activity;
           var content =new AppInviteContent.Builder().SetApplinkUrl(appLinkURL).SetPreviewImageUrl(previewImageURL).Build() as AppInviteContent;
            AppInviteDialog.Show(activity, content);
        }
    }

以Xamarin形式使用

  var facebookservice=Dependency.Get<IFacebookservice>()
    button.click+=delegate{facebookservice.InviteFriends("appurl","previewimageurl")}

这篇关于FB App邀请Xamarin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆