简体   繁体   English

在FB.com上移除应用后,FB应用无法从iOS请求权限

[英]FB app fails to ask for permissions from iOS after app removed on FB.com

We found an odd set of circumstances that can cause an error when sharing to Facebook from our iOS application. 我们发现了一组奇怪的情况,当我们从iOS应用程序共享到Facebook时会导致错误。 I'm trying to figure out if it might just be a bug in the way Facebook responds to this set of events or maybe there's a way to avoid it. 我试图弄清楚它是否只是Facebook对这一系列事件做出反应的方式中的错误,或者可能有一种方法可以避免它。

Basically, our iOS app does not re-ask for permissions after a user has revoked permissions from the FB website. 基本上,我们的iOS应用程序在用户撤消FB网站的权限后不会重新请求权限。 We expected our app would re-ask but instead it attempts to share content and then fails with a generic error message. 我们期望我们的应用程序会重新询问,但它会尝试共享内容,然后失败并显示一般错误消息。 There's no opportunity for the user to grant permission again. 用户没有机会再次授予权限。

The exact set of circumstances: 确切的情况:

  1. User wants to share content from iOS app, the FB app connected to it asks for permissions, and everything works. 用户希望从iOS应用程序共享内容,连接到它的FB应用程序请求权限,一切正常。
  2. User removes app from their profile with FB.com app settings. 用户使用FB.com应用程序设置从其个人资料中删除应用
  3. User shares content from iOS app again, and the FB app submits but then returns an error rather than re-ask for permissions. 用户再次从iOS应用程序共享内容,FB应用程序提交,但随后返回错误而不是重新请求权限。

Jeremy 杰里米

The testers figured out they weren't giving the app enough time to clear its cache on the device so there was a mismatch between permissions on the device and permissions on Facebook. 测试人员发现他们没有给应用程序足够的时间来清除设备上的缓存,因此设备权限与Facebook权限不匹配。

Previously, they would remove permissions at FB.com and then immediately try to share from the iOS app. 以前,他们会删除FB.com的权限,然后立即尝试从iOS应用程序共享。 Now, they're reporting that if they wait an hour the app will re-request permissions normally. 现在,他们报告说,如果他们等待一个小时,应用程序将正常重新请求权限。

Thanks! 谢谢!

I don't know what causes your problem, but I might have a work around for you: Set a deauthorize callback url in the advanced app settings. 我不知道是什么原因引起了您的问题,但我可能会为您解决一下:在高级应用设置中设置取消授权的回拨网址。 This way you can catch every user who deauthorizes your app and save it to your data base or whatever. 这样,您就可以捕获每个取消对您的应用授权的用户,并将其保存到您的数据库或其他任何用户。 The url might link to a php file which looks like the following: 该URL可能链接到一个php文件,如下所示:

<?php

$secretKey = "APP_SECRET_KEY";
$data = parse_signed_request($_REQUEST['signed_request'], $secretKey);
$fbUserId = $data['user_id'];
// do with the user id whatever you want

function parse_signed_request($signed_request, $secret) {
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);

    // decode the data
    $sig = base64_url_decode($encoded_sig);
    $data = json_decode(base64_url_decode($payload), true);

    if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
        error_log('Unknown algorithm. Expected HMAC-SHA256');
        return null;
    }

    // check sig
    $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
    if ($sig !== $expected_sig) {
        error_log('Bad Signed JSON signature!');
        return null;
    }

    return $data;
}

function base64_url_decode($input) {
    return base64_decode(strtr($input, '-_', '+/'));
}

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM