【问题标题】:PhoneGap/Cordova 2.2.0 Facebook plugin On IOS FB.init failPhoneGap/Cordova 2.2.0 Facebook 插件在 IOS FB.init 上失败
【发布时间】:2012-11-13 21:06:31
【问题描述】:

我正在开发一个 PhoneGap 2.2.0/IOS 应用程序并且需要使用 FaceBook 插件'我按照 GIT 中描述的安装过程,当我使用示例文件夹中的“简单”示例时 我得到了设备就绪对话框,告诉我将我的 appID 放在适当的位置,我这样做了,然后我按 OK,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>

欢迎任何帮助!

【问题讨论】:

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


    【解决方案1】:

    你的问题在于这一行

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

    应该是:

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

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

    【讨论】:

    • 这是我的第一次尝试,我删除了它,仍然得到相同的结果,你知道一个很好的样本准备好使用 ios 项目吗,我在这个问题上拖了 4 天没有成功跨度>
    • 如你所见,我发现了我的问题,而且你的话是对的,我没有提供所有 plist,所以你看不到我在项目中遇到的所有问题,无论如何你是对的告诉我
    【解决方案2】:

    我发现了问题,它在我的 projectname.plist 上我缺少所需的元素之一,我在执行说明时跳过了它 感谢您的帮助,我现在有一个带有 PhoneGap/Cordova 2.2.0 和 FaceBook 插件的基本 IOS,如果有人需要,我很乐意提供它

    这是解决我问题的 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>
    

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

    【讨论】:

    • 请告诉我们,您跳过了什么元素?
    • 我也遇到了同样的问题,请帮帮我
    • 您好,我正在更新我的答案以尝试在 IOS 上帮助您解决问题,我的问题是在 plist 中添加了几行代码,我会将 plist 代码放入更新后的答案中
    • @ShimonWiener 嘿,Shimon,您是否可以发布您的基本项目供我们用作模板,可能需​​要在哪里更改应用程序 ID 等内容?我个人已经在这方面打败了大约 2-3 天,我遇到的几乎所有东西都已经过时了,我敢肯定这会对我和其他人有很大帮助!
    【解决方案3】:

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

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

    5:配置一个新的 XCode 项目。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-09
      • 1970-01-01
      相关资源
      最近更新 更多