android - How to request new facebook permission without logging out -
i integrating facebook login , publish feed in application. , using android simple facebook
i implemented login flow, , working on publish flow. want following:
when user clicks on share facebook button in app, don't want publish directly want publish permission can publish later (similar instagram, permission @ first , publish when add photo).
for have done this:
if (msimplefacebook.islogin()) { //the user logged in proceed if (msimplefacebook.getgrantedpermissions().contains( permission.publish_action.getvalue())) { haspermission = true; } else { //we don't have permission request it. msimplefacebook.requestnewpermissions( socialutilities.getfacebookpublishpermissions(), true, newpermissionlistener); } }
however if logged in , have session prompted login again before getting permission. have looked in code of simple facebook library , appears logging out , logging in again, , after login requests new permission.
i want ask, why done that? can't request new permission without logging out in again (similar instagram) ? overriding behavior in library impossible sessionmanager private , non accessible.
so there way request new permission without logging out , forcing user login again, using library? or have put aside , implement scratch using native facebook sdk?
thank or clarifications on matter
edit: clarification. in facebook sdk can request new permissions, , user presented new permission screen accept. similar instagram , i'm ok that, that's want. want know why simple facebook library forcing logout before doing so, there way override or have stop using library , reimplement using native facebook sdk? thank
note: please use latest fbandroid api better options , easy integrate.
if want publish permission @ beginning use following code facebook loginbutton
private static final list<string> permissions = arrays.aslist("publish_actions");
else use following permissions login user details
private static final list<string> permissions = arrays.aslist("public_profile","user_friends");
example:(request 1 permission @ time,don't use both)
loginbutton.setreadpermissions(permissions);
for requesting new permissions use following
private void requestfor_new_permissions() { session session = session.getactivesession(); if (session != null) { // check whether have granted these permissions list<string> permissions = session.getpermissions(); if (!issubsetof(permissions, permissions)) { session.newpermissionsrequest newpermissionsrequest = new session .newpermissionsrequest(this, permissions); session.requestnewpublishpermissions(newpermissionsrequest); return; } else { //publish items } } } private boolean issubsetof(collection<string> subset, collection<string> superset) { (string string : subset) { if (!superset.contains(string)) { return false; } } return true; }
Comments
Post a Comment