facebook - Send to Messenger button not showing -


i trying use send messenger plugin not rendered if try initialize fb user's page id , messenger app id. user has given me permission manage pages obtain page id 1 of them (he chooses which). there nothing in messenger docs scenario..

here how it:

flow:

  1. the user logs in using facebook login facebook sdk. gives me manage_pages permission.
  2. i fetch pages fb.api('/me/accounts') , display them user
  3. user selects 1 of these pages
  4. i create send messenger plugin element selected page id , app id, call fb.xfbml.parse() render plugin. not work if page not connected app seems.

my messenger bot not published (still in development).

things tried no results: - tried test users created in app - tried giving user tester role in app's settings

code:

<html> <body>     <script>         // if user logged in fb pages         function statuschangecallback(response) {             if (response.status === 'connected') {                 fetchpages();             }         }          // login listener         function checkloginstate() {             fb.getloginstatus(function(response) {                 statuschangecallback(response);             });         }          // initialize fb         window.fbasyncinit = function() {             fb.init({                 appid: 'xxxx',                 cookie: true,                 xfbml: true,                 version: 'v2.6'             });              fb.getloginstatus(function(response) {                 statuschangecallback(response);             });         };          // load sdk asynchronously         (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/sdk.js";             fjs.parentnode.insertbefore(js, fjs);         }(document, 'script', 'facebook-jssdk'));          function fetchpages() {             fb.api('/me/accounts', function(response) {                  if (response && response.data && !response.error) {                      // pages managed logged in user                     var pages = response.data;                     var pageids = [];                     pagelist.innerhtml = '';                      // user selects 1 of these pages, let's first 1                     var selectedpage = pages[0];                      var pageselector = document.getelementbyid('pageselector');                     pageselector.addeventlistener("click", function() {                          // create send messenger element                         // messenger_app_id: app's id                         // page_id: id of selected page                         var sendtomessengerwrapper = document.getelementbyid('sendtomessengerwrapper');                         sendtomessengerwrapper.innerhtml = '';                          var plugin = document.createelement('div');                         plugin.setattribute('class', 'fb-send-to-messenger');                         plugin.setattribute('messenger_app_id', 'xxxx');                         plugin.setattribute('page_id', selectedpage.id);                         plugin.setattribute('data-ref', 'ref');                         plugin.setattribute('color', 'blue');                         plugin.setattribute('size', 'standard');                         sendtomessengerwrapper.appendchild(plugin);                          // re-render button - worked page directly connected app.                          fb.xfbml.parse(document.getelementbyid('sendtomessengerwrapper'));                     });                 }             });         }     </script>      <!-- notice permissions requesting -->     <fb:login-button id="loginbtn" scope="manage_pages,pages_messaging,pages_messaging_phone_number" onlogin="checkloginstate();">     </fb:login-button>      <input type="button" id="pageselector" value="connect page"/>      <!-- plugin button should rendered inside element -->     <div id="sendtomessengerwrapper"></div>    </body> 

the issue webhook of app not subscribed page. if subscription had not been made through app settings of messenger product, or through graph api button not appear.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -