facebook messenger - close webview and notify webhook -
i'm sending user messenger chat payment page in application. messenger opens page in webview. i'd close webview , send user messenger while sending webhook in order notify user has finished payment page.
what best way accomplish this?
you can achieve if payment page controlled(developed you), if third party payment gateway there nothing can do. if payment page controlled you, can pass sender id parameter via web_url or sender id via
<script> (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.com/en_us/messenger.extensions.js"; fjs.parentnode.insertbefore(js, fjs); }(document, "script", "messenger")); window.extasyncinit = function () { // messenger extensions js sdk done loading messengerextensions.getuserid(function success(uids) { var psid = uids.psid;//this page scoped sender_id alert(psid); }, function error(err) { alert("messenger extension error: " + err); }); }; </script>
using sender id can send message text bot. close webview after of include script after sending text bot
<script> (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.com/en_us/messenger.extensions.js"; fjs.parentnode.insertbefore(js, fjs); }(document, "script", "messenger")); window.extasyncinit = function () { // messenger extensions js sdk done loading //close webview messengerextensions.requestclosebrowser(function success() { }, function error(err) { }); }; </script>
just within bot have ensure page access token available before send text, ensure whitelist domain used in webview , set "messenger_extensions": true, in web_url button or won't able sender id using messenger extension
references
Comments
Post a Comment