Ionic/Cordova应用程序中的Facebook帐户套件

Zah*_*man 8 facebook angularjs cordova ionic-framework

我尝试在Ionic/cordova应用程序中连接Facbook帐户工具包,我面临的主要问题是在facebook帐户工具包中设置客户端/服务器端域名,但在ionic/cordova app中,webview服务来自文件系统("file:/// android_asset/WWW/index.html的#/应用/请求").那么如何在Ionic应用程序中执行此操作.

Sun*_*l M 2

您可以使用插件代替 webview https://github.com/gurisko/cordova-plugin-accountkit

脚步:

  1. 从https://developers.facebook.com创建 Facebook 应用程序
  2. 启用Accountkit;复制所需的凭据
  3. 添加AccountKit插件

cordova plugin add 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)
})
Run Code Online (Sandbox Code Playgroud)

如果 Ionic 带有打字稿,只需在函数之前添加(窗口)

(<any>window).AccountKitPlugin.loginWithPhoneNumber({
    useAccessToken: true,
    defaultCountryCode: "US",
  },function(res){
    console.log(res)
  },function(err){
     console.log(err)
})
Run Code Online (Sandbox Code Playgroud)

参考: https: //codesundar.com/ionic-accountkit-integration/