我正在使用ionic4创建一个使用google-plus api登录的android /浏览器应用程序。 我设法设置了添加模块所需的配置(webClientId和反向...)
此处是导入和配置
import { GooglePlus } from '@ionic-native/google-plus/ngx' ;
import { AngularFireModule } from 'angularfire2';
import { AngularFireAuth } from 'angularfire2/auth';
import firebase from 'firebase' ;
export const firebaseConfig2={
apiKey: "***",
authDomain: "**-**.firebaseapp.com",
databaseURL: "https://***-**.firebaseio.com",
projectId: "winwin-***",
storageBucket: "winwin-****.appspot.com",
messagingSenderId: "******"
}
firebase.initializeApp(firebaseConfig2)
************
imports: [
BrowserModule,
HttpClientModule,
HttpModule,
IonicModule.forRoot(MyApp,{
tabsPlacement: 'top',
}),
IonicStorageModule.forRoot(),
AngularFireModule.initializeApp(firebaseConfig2),
],
*********
providers: [
******
Geolocation,
GooglePlus,
AngularFireAuth
]
我在浏览器和android中遇到相同的错误(科尔多瓦运行浏览器/ android)
LoginPage.html:19 ERROR TypeError: Object(...) is not a function
at GooglePlus.login (index.js:27)
at LoginPage.webpackJsonp.64.LoginPage.loginfirebase (login.ts:45)
at Object.eval [as handleEvent] (LoginPage.html:19)
at handleEvent (core.js:13589)
at callWithDebugContext (core.js:15098)
at Object.debugHandleEvent [as handleEvent] (core.js:14685)
at dispatchEvent (core.js:10004)
at core.js:10629
at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
at t.invokeTask (polyfills.js:3)
loginGoogle(){
this.googleplus.login({
'webClientId':'****-*****.apps.googleusercontent.com',
'offline':true
}).then(res=>{
firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken))
.then(suc=>{
alert('HALLALOUYA')
}).catch(ns=>{
alert ('not succ')
})
})
}
找不到这个错误的人的问题
无法判断我是否有插件版本错误或配置搞乱了。
答案 0 :(得分:2)
从2019年3月开始将不支持使用Google Plus登录名,并且在此之前可能会停止工作。您应该migrate登录Google登录。
答案 1 :(得分:0)
对我来说,这是安装 @ionic-native/google-plus 时的版本不匹配
如果您使用的不是 Ionic 5,则需要获取早期版本。究竟是哪一个?
对于 Ionic 3.9 npm i @ionic-native/google-plus@4.16
作品。
对于 4.0,我想您可以尝试 4.20.0。关键是安装后,查看 node_modules\@ionic-native\google-plus\package.json
并检查 peepDependencies
下的项目是否符合所有要求。