Phonegap Android Facebook plugin publish_stream permission request throws “Error calling method on NPObject”

本秂侑毒 提交于 2019-12-13 17:23:03

问题


I'm using Phonegap for Android and I have just integrated Facebook plugin(https://github.com/phonegap/phonegap-facebook-plugin) to my project. I need to get an AccessToken that could be sent to server so that server could post on user's behalf.


When I at first called FB.login(callback, {scope:'email,user_birthday,user_location'}) everything works fine and dandy. But if I add 'publish_stream' permission to the scope I get an error: "Uncaught Error: Error calling method on NPObject". Error is originating from cordova.js (phonegap 2.8) on line 863 which is: var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson); I initialize the plugin in the next manner:

        FB.init({
            appId: Global.Facebook.apiKey,
            nativeInterface: CDV.FB,
            useCachedDialogs: false,           
        });

If I remove that permission from scope all works ok. Perhaps anyone has some experience or thoughts on how to fix such issue? I debug my app on my phone (Samsung Galaxy S2 connected via USB debugging feature) and for IDE I use adt-bundle's Android Developer Tools (basicly eclipse);

Many thanks in advance.


回答1:


I seem to have gotten to the root of the problem. When logging in initially, I can't ask for write ("publish") permissions. As I understand I must ask them later after initial login. Which is abit uncomfortable for me, since I might have to prompt user for permissions several times during a single use-case which is bad. Perhaps I am missing some documentation page where all that stuff is already mentioned?




回答2:


I've founded !!

Go to FacebookSDK Project -> Properties -> Java Build Path -> Order and Export (tab) -> Make sure android-support-v4.jar is checked. Then do a clean and launch...

Great ?




回答3:


Use this in your session for publish and read permissions (extended permission.)

session.reauthorizeForPublish



来源:https://stackoverflow.com/questions/17362412/phonegap-android-facebook-plugin-publish-stream-permission-request-throws-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!