Messenger Extensions Javascript SDK Error 2071011
Asked Answered
G

3

9

I'm trying to create a Messenger Web View (https://developers.facebook.com/docs/messenger-platform/messenger-extension) by using the Messenger Extensions Javascript SDK.

The page opened by the Web View has the following JS code

<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 () {
    // the Messenger Extensions JS SDK is done loading
    MessengerExtensions.getUserID(function success(uids) {
        var psid = uids.psid;
        alert(psid);
    }, function error(err) {
        alert("Messenger Extension Error: " + err);
    });
};
</script>  

And the result is an Alert with the following message "Messenger Extension Error: 2071011". So the method "getUserID" goes in error. What "2071011" error code means? And how to solve it? I've searched a lot but nothing has been found about it.

Any help is really appreciated!!

PS: the guide says to whitelist the site of the URL and I've done that too.

Gowon answered 8/11, 2016 at 15:15 Comment(6)
having the exact same problem thanks for postingPrejudicial
Same problem found in there, have anyone solved it? Please help me.Lowtension
Maybe I found it, i was missing the ""messenger_extensions": true," in the button...hope it helps youGowon
Also have this problem here. I have "messenger_extensions: true", I dont think this is the problemTeddman
Same problem for me ... I created a similar question : #40756947Anesthesiologist
In my case, its working fine in mobile app. But not working in desktop websiteYap
P
3

How are you trying to open the webview? I was facing the same issue but then messenger extensions only work on iOS and Android as per the documentation. This code works for me on iOS and throws the same error on desktop messenger app. I hope this helps.

Pressing answered 18/11, 2016 at 9:54 Comment(4)
@harpreetSingh : which version of messenger app you are using? Is it iOS or android? Make sure it's latest version. And you can try an alert to check if your JS loads. window.extAsyncInit = function () { alert(""Messenger Extensions JS SDK is done loading"); // the Messenger Extensions JS SDK is done loading MessengerExtensions.getUserID(function success(uids) { var psid = uids.psid; alert(psid); }, function error(err) { alert("Messenger Extension Error: " + err); }); };Pressing
I found that its valid bug and facebook team is working on it......here is link developers.facebook.com/bugs/1676913532599603Sagunto
Yes, I saw the bug. Its working fine for me and I am able to get the user details :)Pressing
What do you mean by in website? It works on iOS and Android messenger with the latest version but it doesn't work on my desktop.Pressing
R
4

I found "2071011" error explanation in messenger.Extensions.js minified source:

if (!p) {
    x(2071011, 'JavaScript bridge does not exist - Please make sure you are in latest ' + 'version of Facebook or Messenger App.');
    return;
}

p value equals q():

function q() {
    switch (o) {
        case h.ANDROID:
            return window._FBExtensions;
        case h.IOS:
            return window.webkit && window.webkit.messageHandlers;
    }
    return null;

}

Possible error causes:

  1. Please ensure you have the newest Messenger App version (do not resolve problem in my case).
  2. It is highly possible that Messenger Android app do not include variable window._FBExtensions into WebView context properly - I have this variable undefined and messenger.Extensions.js assumes that _FBExtensions variable already exists. I can't found currently workaround for this as it is Messenger App part.
Ramos answered 24/11, 2016 at 16:10 Comment(1)
window._FBExtensions adding this variable will make it work? I tried but not working. What should be the value of the variable? @RamosYap
P
3

How are you trying to open the webview? I was facing the same issue but then messenger extensions only work on iOS and Android as per the documentation. This code works for me on iOS and throws the same error on desktop messenger app. I hope this helps.

Pressing answered 18/11, 2016 at 9:54 Comment(4)
@harpreetSingh : which version of messenger app you are using? Is it iOS or android? Make sure it's latest version. And you can try an alert to check if your JS loads. window.extAsyncInit = function () { alert(""Messenger Extensions JS SDK is done loading"); // the Messenger Extensions JS SDK is done loading MessengerExtensions.getUserID(function success(uids) { var psid = uids.psid; alert(psid); }, function error(err) { alert("Messenger Extension Error: " + err); }); };Pressing
I found that its valid bug and facebook team is working on it......here is link developers.facebook.com/bugs/1676913532599603Sagunto
Yes, I saw the bug. Its working fine for me and I am able to get the user details :)Pressing
What do you mean by in website? It works on iOS and Android messenger with the latest version but it doesn't work on my desktop.Pressing
R
0
MessengerExtensions.getUserID(function success(uids) {
            // triggering on devices
            self.defer.resolve(uids.psid);
        }, function error(err) {
            MessengerExtensions.getContext(config.fbApp.id, function success(result) {
                // triggering on desktop
                self.defer.resolve(result.psid);
            }, function error(result) {
                self.defer.reject(result);
                console.log('Context Error ', result);
            });
        });
Revelationist answered 2/11, 2017 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.