Facebook设置SessionDefaultAudience

Facebook设置SessionDefaultAudience

本文介绍了如何在Android中为Facebook设置SessionDefaultAudience的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去两天我已经搜索了很多,而且我没有成功。我正在跟随链接进行设置Facebook本地登录。我添加以下代码到 SplashFragment.java

I have searched a lot for past two days and I was not successful. I am following the Authenticate-Facebook Developers link for setting up the Facebook native login. I add the following code to SplashFragment.java:

authButton = (LoginButton) view.findViewById(R.id.fb_logIn_btn);
authButton.setPublishPermissions(PERMISSION);
authButton.setDefaultAudience(SessionDefaultAudience.ONLY_ME);

但这不行。

在我的应用程序中,我想提醒用户进入隐私模式( SessionDefaultAudience.EVERYONE SessionDefaultAudience.ONLY_ME SessionDefaultAudience.FRIENDS )设置他们通过应用程序发布的隐私设置。

In my app, I want to alert the user to enter the privacy mode(SessionDefaultAudience.EVERYONE or SessionDefaultAudience.ONLY_ME or SessionDefaultAudience.FRIENDS ) to set their privacy setting for their post through the application.

我还经历了
但是如何实现呢?

I also went through Session.NewPermissionsRequest-Facebook Developersbut how to implement this?

推荐答案

您可以更改观众和权限:

You can change the audience and the Permission like that:

private void requestPublishPermissions(Session session) {
    if (session != null && !session.getPermissions().contains("publish_actions")) {
        System.out.println("SEESION Permission");
        Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(mainFragment, Arrays.asList("publish_actions"));
        // demonstrate how to set an audience for the publish permissions,
        // if none are set, this defaults to FRIENDS
          .setDefaultAudience(SessionDefaultAudience.FRIENDS);
        session.requestNewPublishPermissions(newPermissionsRequest);
    }
}

只需将此行更改为您想要的受众群体



Just change this line to the audience you want

.setDefaultAudience(SessionDefaultAudience.FRIENDS);

这篇关于如何在Android中为Facebook设置SessionDefaultAudience的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 07:14