我尝试在 Ionic/cordova 应用程序中连接 Facbook 帐户工具包,我遇到的主要问题是在 facebook 帐户工具包中设置客户端/服务器端域名,但在 ionic/cordova 应用程序中,webview 从文件系统提供服务(“file:///android_asset/www/index.html#/app/request”)。那么如何在 Ionic 应用程序中执行此操作。
最佳答案
你可以使用插件代替webview https://github.com/gurisko/cordova-plugin-accountkit
步骤:
- 从 https://developers.facebook.com 创建一个 Facebook 应用程序
- 启用 Accountkit;复制所需凭据
- 添加 AccountKit 插件
cordova 插件添加 cordova-plugin-accountkit --save --variable APP_ID="123456789"--variable APP_NAME="myApplication"--variable CLIENT_TOKEN="abcdefghijklmnopqrstuvwxyz"
AccountKitPlugin.loginWithPhoneNumber({
useAccessToken: true,
defaultCountryCode: "US",
},function(res){
console.log(res)
},function(err){
console.log(err)
})
如果 Ionic 带有 typescript,只需在函数前添加 (window)
(<any>window).AccountKitPlugin.loginWithPhoneNumber({
useAccessToken: true,
defaultCountryCode: "US",
},function(res){
console.log(res)
},function(err){
console.log(err)
})
关于angularjs - Ionic/Cordova 应用中的 Facebook Account Kit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38634209/