我正在使用ionic4创建一个android/浏览器应用程序,该应用程序使用google+ api进行登录。我设法设置了添加模块所需的配置(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中得到相同的错误(cordova运行浏览器/ 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')
})
})
}问题是我找不到任何有这个错误的人
我不知道我是否有一个插件版本错误或我已经搞乱了配置。
发布于 2019-01-08 21:53:27
从2019年3月开始,将不支持使用Google Plus登录,并可能在此之前停止工作。你应该通过migrate登录到谷歌。
发布于 2021-01-26 14:28:44
对我来说,这是安装@ For 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下检查,以查看您的项目是否符合所有要求。
https://stackoverflow.com/questions/54092352
复制相似问题