FB.login broken flow for iOS WebApp

前端 未结 2 1359
长发绾君心
长发绾君心 2020-12-13 01:04

I\'m making an iOS Webapp (i.e. an HTML page that runs in standalone mode - none of the Safari chrome - when the bookmark of the page is added to the homescreen).

I

相关标签:
2条回答
  • 2020-12-13 01:35

    You can try the workaround below. It worked for me. In mobile, it redirects to client side authentication url.

    var isMobile = false;
    try {
        isMobile = (window.location.href == top.location.href && window.location.href.indexOf("/mobile/") != -1);
    } catch (e) {}
    if (!isMobile) {
        FB.login();
    } else {
        var permissionUrl = "https://m.facebook.com/dialog/oauth?client_id=" + appId + "&response_type=code&redirect_uri=" + redirectPage + "&scope=" + permissions;
        window.location = permissionUrl;
        return;
    }
    
    0 讨论(0)
  • 2020-12-13 01:35

    I used the following to detect if I'm in home screen mode and do the right thing accordingly:

    if ("standalone" in navigator && navigator.standalone) {
      var permissionUrl = "https://m.facebook.com/dialog/oauth?client_id=" + appId + "&response_type=code&redirect_uri=" + window.location + "&scope=" + app_permissions;
      window.location = permissionUrl;
    } else {
      FB.login(
        function(response) {
          ...
        },
        {scope: app_permissions}
      );
    }
    
    0 讨论(0)
提交回复
热议问题