我正在尝试关注this tutorial在Ionic应用中使用GooglePlus登录。我已经按Eddy Verbruggen安装了该插件,根据教程,我应该在home.ts
的顶部添加此行。
import { GooglePlus } from 'ionic-native';
当我尝试构建时,Ionic抱怨了。改变它有助于
import { GooglePlus } from '@ionic-native/google-plus';
但是现在以下代码不会转换
GooglePlus.login({.....
因为“类型'类型'GooglePlus'上不存在”属性'登录'“。使用WebStorm我可以控制点击GooglePlus,它会转到node_modules/@ionic-native/google-plus
中的类定义,它表明该类显然有一个名为login的函数。
答案 0 :(得分:1)
本教程中我需要的这些更改部分详见Ionic's docs
1)将GooglePlus添加到构造函数
@ExceptionHandler({ ResourceNotFoundException.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public ResponseEntity<Object> handleResourceNotFound(ResourceNotFoundException ex, WebRequest request) {
ErrorResponseProperty property = ErrorResponseProperty.builder()
.id("req_id")
.message("resource not found")
.status(Integer.toString(Response.SC_NOT_FOUND)).build();
List<ErrorResponseProperty> propertyList = new ArrayList<ErrorResponseProperty>();
propertyList.add(property);
ErrorResponsePOJO responsePOJO = ErrorResponsePOJO.builder()
.errors(propertyList).build();
return new ResponseEntity<Object>(responsePOJO, HttpStatus.NOT_FOUND);
}
@ExceptionHandler({ NoHandlerFoundException.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public ResponseEntity<Object> handleResourceUnavailable(NoHandlerFoundException ex, WebRequest request) {
ErrorResponseProperty property = ErrorResponseProperty.builder()
.id("req_id")
.message("resource not found")
.status(Integer.toString(Response.SC_NOT_FOUND)).build();
List<ErrorResponseProperty> propertyList = new ArrayList<ErrorResponseProperty>();
propertyList.add(property);
ErrorResponsePOJO responsePOJO = ErrorResponsePOJO.builder()
.errors(propertyList).build();
return new ResponseEntity<Object>(responsePOJO, HttpStatus.NOT_FOUND);
}
2)将constructor(private googlePlus: GooglePlus) { }
更改为GooglePlus.login()
3)导入GooglePlus并将其作为提供商添加到this.googlePlus.login
app.module.ts
...
import { GooglePlus } from '@ionic-native/google-plus';