Search code examples
webviewfacebook-messenger-bot

Messenger extension in not working in webview


After whitelisting my domain, I try to access messenger extension to get the user ID, it failed with error :

Messenger Extensions are not enabled - could be "messenger_extensions" was not set on a url, the domain was not whitelisted or this is an outdated version of Messenger client

I tried the messenger on google chrome and firefox same error is appearing. messenger_extensions is set to true and domain is whitelisted; I confirmed.

Why is it bring that message?


Solution

  • Are you trying to access it through a browser? If so that may be why you are having issues.

    Try access the url through the messenger app on your phone. This will iFrame in the web page and you will have access to the MessengerExtensions sdk.

    Not sure how you are supposed to be able to log within messenger though. I did something like this to test it out

    window.extAsyncInit = function() {
    // the Messenger Extensions JS SDK is done loading
        MessengerExtensions.getUserID(function success(uids) {
            // User ID was successfully obtained. 
            var psid = uids.psid;
            console.log("psid", psid)
                $('.error').html(psid)
    
        }, function error(err, errorMessage) {      
            // Error handling code
            console.log(err, errorMessage)
            $('.error').html(errorMessage)
        });    
    };