Help me a example share facebook in ios with these!
NguyenThuTrang opened this issue · 1 comments
NguyenThuTrang commented
i can't share facebook with robovm-ios-bindings. Help me, please?
jsras commented
This code works for me:
public void shareOnFacebook() {
NSOperationQueue.getMainQueue().addOperation(new Runnable() {
@Override
public void run() {
FBLinkShareParams shareDialog = new FBLinkShareParams(new NSURL("URLTOSHARE"),
"TITLE",
"CAPTION!",
"DESCRIPTION",
new NSURL("URLTOICON"));
if (FBDialogs.canPresentShareDialog(shareDialog)) {
FBDialogs.presentShareDialog(shareDialog, new NSDictionary<NSObject, NSObject>(), new FBDialogAppCallCompletionHandler() {
@Override
public void invoke(FBAppCall fbAppCall, NSDictionary<?, ?> nsDictionary, NSError nsError) {
if (nsError != null) {
alertError("Error!", new FacebookError(nsError.getLocalizedDescription(), true));
}
}
});
}else {
HashMap params = new HashMap();
params.put("caption","CAPTION");
params.put("link", "URL");
params.put("picture", "URLTOICON");
params.put("name", "TITLE");
params.put("description","DESCRIPTION");
FBWebDialogs.presentFeedDialog(FBSession.getActiveSession(), params, new FBWebDialogHandler() {
@Override
public void invoke(FBWebDialogResult fbWebDialogResult, NSURL nsurl, NSError error) {
}
});
}
}
});
Both methods are required, since you dont know if they have the facebook app installed or not.