本文介绍了Swift 2.0代码为Facebook Friend邀请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我一直在为iOS应用程序的Facebook朋友邀请寻找一个等效的Swift代码示例。但是我找不到它们。

I've been looking for an equivalent Swift code sample for Facebook friend invite for iOS apps. But I can't find them.

我明白Facebook页面上有Objective-C版本。然而,因为我开始与斯威夫特,我发现很难翻译。

I understand that there is the Objective-C version on Facebook page https://developers.facebook.com/docs/app-invites/ios. However, because I started off with Swift, I find it difficult to translate.

有人可以指出我来源吗?谢谢。

Could someone point me to a source? Thank you.

推荐答案

代码工作:

- 在viewDidLoad :

-In viewDidLoad :

let content = FBSDKAppInviteContent()
content.appLinkURL = NSURL(string: "https://test/myapplink")
content.appInvitePreviewImageURL = NSURL(string: "https://test/myapplink")
// Old Way, now depreciated :
//FBSDKAppInviteDialog.showFromViewController(self, withContent: content, delegate: self)
//New way :
        FBSDKAppInviteDialog.showFromViewController(self, withContent: content, delegate: self)
// Do any additional setup after loading the view.

- 在您的viewController中符合协议委托:

-In your viewController to conform the protocol delegate:

extension InviteFriendsViewController: FBSDKAppInviteDialogDelegate{
    func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [NSObject : AnyObject]!) {
        //TODO
    }
    func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!) {
        //TODO
    }
}

这篇关于Swift 2.0代码为Facebook Friend邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:30