PhoneGap / Cordova 2.2.0 Facebook插件在IOS FB.init失败

时间:2012-11-13 21:06:32

标签: ios facebook cordova facebook-javascript-sdk phonegap-plugins

我正在开发一个PhoneGap 2.2.0 / IOS应用程序并需要使用FaceBook插件'我按照GIT中所述的安装过程,当我使用示例文件夹中的“简单”示例时 我得到设备准备好的对话框,告诉我把我的appID放到位,我做了,然后按下确定,IOS抛出了这个错误:

'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: No AppID provided; either pass an AppID to init, or add a string valued key with the appropriate id named FacebookAppID to the bundle *.plist'

听到的是我的FB.init

    document.addEventListener('deviceready', function() {

                              try {
                              alert('Device is ready! Make sure you set your app_id below this alert.');
                              FB.init({ appId: "fb245065455620705", nativeInterface: CDV.FB, useCachedDialogs: false });
                              document.getElementById('data').innerHTML = "";
                              } catch (e) {
                              alert(e);
                              }
                              }, false);

这是添加到我的plist文件中的条目

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>com.mdsitg.amisrael</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb245065455620705</string>
            </array>
        </dict>
    </array>

欢迎任何帮助!

3 个答案:

答案 0 :(得分:3)

你的问题在于这一行

FB.init({ appId: "fb245065455620705", nativeInterface: CDV.FB, useCachedDialogs: false });

应该是:

FB.init({ appId: "245065455620705", nativeInterface: CDV.FB, useCachedDialogs: false });

注意,“fb”不应该是App ID的一部分。

答案 1 :(得分:1)

我发现了问题,它是在我的projectname.plist上我错过了所需的一个元素,我在执行指令时正在滑动它 感谢您的帮助,我现在有一个基础IOS与PhoneGap / Cordova 2.2.0与FaceBook插件工作,如果有任何身体需要一个生病很高兴给它

这是解决我问题的plist的源代码

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>עמישראל</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIconFile</key>
    <string>icon.png</string>
    <key>CFBundleIconFiles</key>
    <array>
        <string>icon-1.png</string>
        <string>icon-72@2x.png</string>
        <string>icon114.png</string>
    </array>
    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>icon-1.png</string>
                <string>icon-72@2x.png</string>
                <string>icon114.png</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
    </dict>
    <key>CFBundleIdentifier</key>
    <string>com.mdsitg.amisrael</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>com.mdsitg.amisrael</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb245065455620705</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>FacebookAppID</key>
    <string>245065455620705</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string></string>
    <key>NSMainNibFile~ipad</key>
    <string></string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

如果您需要更多帮助,请问我

答案 2 :(得分:0)

您是否尝试将FacebookAppID键/值添加到* -info.plist?

转到https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/,然后点击:

5:配置新的XCode项目。

向下滚动至:“添加您的Facebook App ID”

基本上你需要找到你的projectname-info.plist并添加一个新的键/值对。密钥将是FacebookAppID,价值将是您的应用程序ID 245065455620705(前面没有FB。)