Nếu chỉ cần permission public_profile và email thì ko cần xin quyền từ facebook, còn khi muốn get pages hoặc 1 số cái khác thì phải xin quyền từ fb. link xin quyền và hướng dẫn xin quyền có trong link dưới. Nó yêu cầu cả icon và 1 số thông tin liên quan đến app, nên cần chuẩn bị trước.
link docs các permissions: https://developers.facebook.com/docs/facebook-login/permissions/#reference-manage_pages
link xin quyền:
https://developers.facebook.com/docs/apps/review#app-review
sau khi xin quyền thì ở login code của mình:
bình thường nếu ko xin quyền khác thì nó sẽ như này:
LoginManager.logInWithReadPermissions(['email', 'public_profile'])
còn xin thêm quyền khác thì nó là 1 mảng và đc cách nhau bởi dấu cách luôn chứ ko phải 2 hay nhiều mảng, mình k thấy docs có ghi, hỏi mới biết.
Và sau khi add thêm quyền nó sẽ như này:
LoginManager.logInWithReadPermissions(['public_profile manage_pages pages_show_list pages_messaging pages_messaging_subscriptions email read_page_mailboxes'])
Add quyền xong nếu gặp lỗi:
given URL is not allowed by the application configuration: one or more of the given URLs is not allowed by the app's setting. to use this URL you must add a valid native platform in your app's settings.
thì làm theo hướng dẫn này:
https://stackoverflow.com/questions/48541595/facebook-login-error-with-facebook-login-sdk-android-gives-given-url-is-not-al
( bước này thường nếu bạn tự setup từ đầu thì sẽ có bước này rồi nên sẽ ko gặp lỗi về sau, còn mình được cấp appid từ người khác nên họ ko config cái này nên sẽ gặp lỗi.
Thanks @quỳnh ruby xinh gái, @vũ văn toán.