2016-12-30 30 views
0

我正在關注此文檔(https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-cordova-get-started-users),以將Azure/Facebook身份驗證添加到ionic 2應用程序。將Azure/Facebook驗證添加到ionic 2/cordova/angular 2應用程序?

在工序(3)中,有

打開WWW/JS/index.js用於編輯文件,找到onDeviceReady()方法,並且在所述客戶端創建代碼添加以下代碼:

但是,我在腳手架離子2項目中找不到文件www/js/index.js。我應該修改哪個文件?只有app下的文件應該被修改?是否有任何一步一步的文件來添加離子2應用程序的Azure身份驗證?

enter image description here

回答

1

可以在app.component.ts添加onDeviceReady代碼中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提供了科爾多瓦插件的支持。檢查this了。它易於安裝。

let permissions = ["public_profile","email"]; 
Facebook.login(permissions) 
.then((response) => { 
    let token = { access_token: response.authResponse.accessToken }; 
    return token; 
}).catch(this.handleError); 

對於azure科爾多瓦有plugin,你可以試試。我沒有嘗試過。

相關問題