cocos2d / cocos2d-js

cocos2d-x for JS
http://www.cocos2d-x.org
MIT License
1.86k stars 490 forks source link

Fail to load FacebookSDK #814

Open bearkids opened 10 years ago

bearkids commented 10 years ago

I am using cocos2d-js-v3.0 final and cocos code ide rc2.

I followed the following guide http://cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/facebook-sdk-on-android/en http://cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/api-reference/zh

I can successful built the APK but whenever I call facebook function, it shows "plugin is not defined".

Really strange, any idea?

jianglong0156 commented 10 years ago

you need to add the code in AppDelegate.cpp

if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

sc->addRegisterCallback(register_all_pluginx_protocols);
sc->addRegisterCallback(register_pluginx_js_extensions);

endif

There is a sample in the samples/js-tests/project/Classes/AppDelegate.cpp

bearkids commented 10 years ago

Thanks @jianglong0156

It seems those 2 callback cannot place after sc->addRegisterCallback(JavascriptJavaBridge::_js_register);

It works fine now if I pack my program into APK.

But it shows "facebook.isLoggedIn is not a function" if I debug with android ADB Mode in Cocos Code IDE.

Thanks again.

jianglong0156 commented 10 years ago

The function isLoggedIn defined in file "jsb_pluginx.js". It usually in your project proj.android/assets,
If you not find it, You can use the Cocos console try again

bearkids commented 10 years ago

Yes, jsb_pluginx.js is located in proj.android/assets. I can also successfully pack the app into APK and login facebook from my app.

But if I debug my app with android ADB Mode in Cocos Code IDE, it shows "facebook.isLoggedIn is not a function". It seems Cocos Code IDE cannot be used to debug facebook SDK function.