konstantinbueschel
2/7/2017 - 9:36 PM

fb-hyperloop.js

var FBSDKShareLinkContent = require("FBSDKShareKit/FBSDKShareLinkContent"),
	FBSDKShareDialog = require("FBSDKShareKit/FBSDKShareDialog"),
	NSURL = require("Foundation/NSURL");

var win = Ti.UI.createWindow({
    backgroundColor: "#fff"
});

var btn = Ti.UI.createButton({
    title: "Trigger Share Dialog"
});

btn.addEventListener("click", function() {
    presentShareDialog({
        link: "http://appcelerator.com",
        description: "Titanium rocks!",
        title: "Ti.Facebook Hyperloop"
    })
});

win.add(btn);
win.open();

function presentShareDialog(params) {
   var content = FBSDKShareLinkContent.alloc().init();
   
   Ti.API.info(content);
      
   content.setContentURL(NSURL.URLWithString(params["link"]));
   content.setContentDescription(params["description"]);
   content.setContentTitle(params["title"]);
   
   var shareDialog = new FBSDKShareDialog();
   shareDialog.setShareContent(content);
   shareDialog.show();
}