FBSDKAppInviteDialogDelegate swift implementation doesn't work
I am trying to implement the FBSDKAppInviteDialogDelegate protocol in my class, but xcode shows me an erro that says "The type of MyClass does not conform to the FBSDKAppInviteDialogDelegate protocol"
Protocol definition:
@protocol FBSDKAppInviteDialogDelegate <NSObject>
/*!
@abstract Sent to the delegate when the app invite completes without error.
@param appInviteDialog The FBSDKAppInviteDialog that completed.
@param results The results from the dialog. This may be nil or empty.
*/
- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results;
/*!
@abstract Sent to the delegate when the app invite encounters an error.
@param appInviteDialog The FBSDKAppInviteDialog that completed.
@param error The error.
*/
- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error;
@end
My code:
Defining my class
class MyClasse: UITableViewController, FBSDKAppInviteDialogDelegate
To bring up the prompt dialog:
var inviteDialog:FBSDKAppInviteDialog = FBSDKAppInviteDialog()
if(inviteDialog.canShow()){
let appLinkUrl:NSURL = NSURL(string: "http://mylink.com")!
let previewImageUrl:NSURL = NSURL(string: "http://mylink.com/image.png")!
var inviteContent:FBSDKAppInviteContent = FBSDKAppInviteContent(appLinkURL: appLinkUrl)
inviteContent.previewImageURL = previewImageUrl
inviteDialog.content = inviteContent
inviteDialog.delegate = self
inviteDialog.show()
}
Implementation of procol methods:
//function of FBSDKAppInviteDialogDelegate
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: NSDictionary!){
// my code here
}
//function of FBSDKAppInviteDialogDelegate
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!){
// my code here
}
The invitation dialog is working. But without a protocol, I cannot get the results.
What am I missing here?
+3
source to share
1 answer
The problem is with NSDictionary. The following works for me:
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [NSObject : AnyObject]!) {
println("Complete invite without error")
}
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!) {
println("Error in invite \(error)")
}
+4
source to share