将Azure / Facebook身份验证添加到ionic 2 / cordova / angular 2 app?

时间:2016-12-30 05:25:34

标签: cordova azure ionic-framework ionic2 azure-mobile-services

我正在遵循此文档(https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-cordova-get-started-users)将Azure / Facebook身份验证添加到离子2应用程序。

在步骤(3)中,有

  

打开www / js / index.js文件进行编辑,找到onDeviceReady()方法,并在客户端创建代码下添加以下代码:

但是,我在scaffold ionic 2项目中找不到文件www/js/index.js。我应该修改哪个文件?并且只应修改app下的文件?是否有任何分步文档为ionic 2 app添加Azure身份验证?

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以在app.component.ts

platform.ready()添加export class MyApp { constructor(platform: Platform ) { platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. } } } 代码
Facebook

添加ionic-native身份验证let permissions = ["public_profile","email"]; Facebook.login(permissions) .then( (response) => { let token = { access_token: response.authResponse.accessToken }; return token; }).catch( this.handleError); 为cordova插件提供支持。检查this。它易于设置。

azure

对于class User < ActiveRecord::Base has_many :notifications def notify #code to notify user end end class Student < User has_many :charges def charge_user #code to charge user end end class Teacher < Student has_many :students has_many :courses def create_course #code to create course end end ,cordova有一个plugin您可以尝试。我没试过。