【问题标题】:CORONA SDK - facebook.showDialog() appears and disappears after a whileCORONA SDK - facebook.showDialog() 出现并在一段时间后消失
【发布时间】:2015-12-30 02:03:40
【问题描述】:

我已将 Facebook 添加到我的应用程序中。

登录没问题,除了 facebook.login() 打开浏览器而不是本机 Facebook 应用程序,但是,当我调用 Facebook.showDialog() 时弹出窗口,但一两秒后它消失了。

请注意,我仅在 iOS 上会出现此行为,而在 Android 上则可以正常工作。

我在我的 game.lua 文件中使用以下代码:

local function facebookListener( event )

    if ( "session" == event.type ) then
      if ( "login" == event.phase ) then
            local access_token = event.token
             facebook.showDialog( "feed", { name = "SuperCool Game Coming soon", description = "Trying to figure out how to get my game to rule the world.", picture = "http://omnigeekmedia.com/wp-content/uploads/2011/05/omniblaster_promo-300x300.png", link = "http://www.omnigeekmedia.com/"})
        end

    elseif ( "request" == event.type ) then
        print("facebook request")
        if ( not event.isError ) then
            local response = json.decode( event.response )

        end

    elseif ( "dialog" == event.type ) then
        print( "dialog", event.response )

    end
end

fbAppID = "my app ID"  --replace with your Facebook App ID
function logOnFacebook(event)
    if(event.phase=="ended")then
        facebook.login( fbAppID, facebookListener, { "user_friends", "publish_actions" } )
    end
end

["facebook"] =
{                
 publisherId = "com.coronalabs", 
 supportedPlatforms = { iphone = true, ["iphone-sim"] = true },
},

我正在构建 2015.2729 上运行。

我怎样才能设法让 Facebook 工作?

【问题讨论】:

    标签: facebook login lua coronasdk showdialog


    【解决方案1】:

    我建议更新到插件的 v4 版本。虽然它在技术上仍处于测试阶段,但它是 iOS 9 构建所必需的。见:

    https://coronalabs.com/blog/2015/07/24/facebook-v4-plugin-android-beta/ https://coronalabs.com/blog/2015/09/01/facebook-v4-plugin-ios-beta-improvements-and-new-features/

    【讨论】:

      【解决方案2】:

      浏览source code of the old Facebook plugin,如果请求的权限未被授予,则会出现此错误!

      在旧版 Facebook 插件的源代码中,这可以在 FBSessionReauthorizeResultHandlers 中看到。

      for ( int i = 0; i < [publishPermissions count]; i++)
      {
          if ( ![publishSession.permissions containsObject:[publishPermissions objectAtIndex:i]] )
          {
              release = true;
              publishError = [[NSError alloc] initWithDomain:@"com.facebook" code:123 userInfo:nil];
              break;
          }
      }
      

      对于已请求但未授予的读取权限也会发生这种情况。

      该问题已在Facebook-v4 plugin 中得到修复。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-08
        • 2012-04-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多