ccsoft / cordova-facebook

Cordova plugin that handles Facebook integration in mobile apps.
Apache License 2.0
87 stars 43 forks source link

Add Facebook-App-ID persistent for Android #67

Open hirbod opened 9 years ago

hirbod commented 9 years ago

Dear @koraybalci,

how did you enter your Facebook AppID for Android? iOS was no problem at all, but the explanation for Android https://developers.facebook.com/docs/android/getting-started is confusing and I never found a way to implement it (need to change something in AndroidManifest + res/values/strings.xml)

But strings.xml will be overwritten everytime I do a build or run in cordova-cli.

Nontheless, the APP works fine without it but I think that maybe my Android 5 issues are related to the missing APP-ID. Could you show me your files (of course with censored ID) and how you add them persistent? Thank you very much!

The official Facebook Plugin has a custom.xml file (and they are using --variable method and generating automatic there own facebook.xml, with custom_rules.xml or something) https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/android/README.md

hirbod commented 9 years ago

Ok, for now, I've found a simple way. Seems like cordova automatically import custom.xml files inside of that res/values/ folder.

Just created a facebookconnect.xml

with

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="fb_app_id">1234566</string>
    <string name="fb_app_name">MyAppName</string>
</resources>

And inside of my AndroidManifest.xml inside of Application

        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <activity android:label="@string/fb_app_name" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />

This will break on an update, but for now, it's fine. But it seems it isn't that hard to

a) Include Facebook-Lib automatically as reference (currently very annoying doing with eclipse) b) Change plugin.xml to Accept APP_ID and APP_NAME. There is also a PR for iOS, and Android is quite easy, too. Just need to define a custom.xml and do a little bit of config.

https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/plugin.xml

I like this plugin very much, but it will just be perfect when installation is also made with some variables instead of config trough XCode and Eclipse.