Session: an attempt was made to request new permissions for a session that has a pending request

后端 未结 1 979
悲&欢浪女
悲&欢浪女 2021-01-13 09:44

I want to publish story via Android app and I use a code below.

    private static final List PERMISSIONS = Arrays.asList(\"publish_actions\");         


        
相关标签:
1条回答
  • 2021-01-13 10:42

    First of all, your initFacebookSession method is useless since you call Session.getActiveSession() right below it, so you can delete this method.

    Next, you should handle SessionState changes in onSessionStateChange method. While you don't and only place where you call publishAddCardStory method is in onCreate, I assume the reason you get that errors is this:

    1. you call publish method in onCreate
    2. in publish method you call requestNewPermissions over Session, therefore your activity would be destroyed and facebook activity with dialog that requests allowing new permissions from user appears and Session get into pending state
    3. user would allow (or not) new permissions via dialog
    4. your activity is created again, therefore you call newPermissionsRequest over Session again while Session is still in pending state while onSessionStateChange was not called yet

    Try to look to Facebook Dev Tutorials: https://developers.facebook.com/docs/android/scrumptious/ how to handle SessionState changes. Facebook SDK also provides some sample applications that may be helpful as well. Good luck! :)

    0 讨论(0)
提交回复
热议问题