IN NativeScript无法连接到Facebook

问题描述 投票:0回答:1

我已经安装了pod

在'FacebookSDK'下,

在'FBSDKCoreKit'下

在'FBSDKLoginKit'下

这是正确安装的。通过pod文件。

我的app.js里面的代码

const application = require("tns-core-modules/application"); 
if(application.ios){
var AppDelegate = NSObject.extend({
       applicationDidFinishLaunchingWithOptions :function (application, launchOptions) {
         var gglDelegate = false;
         try {
            var errorRef = new interop.Reference();
            GGLContext.sharedInstance().configureWithError(errorRef);
            var signIn = GIDSignIn.sharedInstance();
            gglDelegate = true;
        } catch (error) {  console.log(error);    }
        var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions); // facebook login delegate
                                  return gglDelegate || fcbDelegate;
      },
     applicationOpenURLSourceApplicationAnnotation : function (application, url, sourceApplication, annotation) {
         var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation); // facebook login delegate
          var gglDelegate = GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url, sourceApplication, annotation); // google login delegate
           return fcbDelegate || gglDelegate;
        }                         
},{
     name: "AppDelegate",
     ObjCProtocols:[UIApplicationDelegate , UIResponder ]  
});  
}
application.run({ moduleName: "app-root" });

我正在尝试使用演示https://github.com/mkloubert/nativescript-social-login/tree/master/demo,但在我的项目中。但我没有使用任何nativescript框架。我的项目基于简单的普通javascript demo.typescript或angular对我的项目不起作用。

但我仍然有这个错误

enter image description here

facebook-javascript-sdk nativescript
1个回答
0
投票

看起来你的语法不正确。从UIResponder扩展并使用protocols而不是ObjCProtocols,当它作为扩展函数的第二个参数传递时。

var AppDelegate = UIResponder.extend({
    ....
    ....
}, {
    name: "AppDelegate",
    protocols: [UIApplicationDelegate]
});

并在运行应用程序之前设置委托,

application.ios.delegate = AppDelegate
© www.soinside.com 2019 - 2024. All rights reserved.