facebook-javascript-sdk - 在 NativeScript 中无法连接到 Facebook
问题描述
我已经安装了吊舱
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 不适用于我的项目。
但我仍然有这个错误
解决方案
看起来你的语法不正确。扩展UIResponder
并使用protocols
而不是ObjCProtocols
将其作为第二个参数传递给扩展函数。
var AppDelegate = UIResponder.extend({
....
....
}, {
name: "AppDelegate",
protocols: [UIApplicationDelegate]
});
并在运行应用程序之前设置委托,
application.ios.delegate = AppDelegate
推荐阅读
- codesniffer - PHP CodeSniffer 是否支持 Rubcop 等特定于规则的配置?
- javascript - 在Javascript中为特定对象键赋值
- python - 更改 django 的默认管理员,但不将模型重定向到默认管理员
- ruby-on-rails - 用设计安装导轨(HEAD版)的正确方法
- c# - 使用网络掩码验证 IPAddress.TryParse
- python - 这是 pypy 的用例吗?
- .net - “计划并等待运行”的任务未运行
- java - 重构代码中的问题/找出要使用的设计模式
- javascript - 谷歌地图不输入www就坏了
- typescript - 使用 TypeScript 和 webpack 在项目之间共享代码