(function(d, s, id){
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) {return;}
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/en_US/messenger.Extensions.js";
	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'Messenger'));
		
function closeWebView(){
	MessengerExtensions.requestCloseBrowser(function success() {
		console.log("webview closed");
	}, function error(err) {
		console.log(err);
	});
}

function shareToMessenger(message){
	MessengerExtensions.beginShareFlow(function(share_response) {
	  if(share_response.is_sent){
	  	alert('已成功發送邀請');
	  }
	}, 
	function(errorCode, errorMessage) {    

	},
	message,
	"broadcast");
}