大佬教程收集整理的这篇文章主要介绍了api – HTTPS请求仅在iOS,Ionic 2上失败,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
API POST请求适用于除iOS之外的所有内容.
我在服务器上的SSL证书是自签名的(可能就是这样吗?).
适用于:
>离子服务
> @L_607_7@
>邮差
>卷曲
这是请求:
public sendNotificationrequest(title: String,action: String,name: String,tokens: any,notifications: Boolean) { // check if user turned off notifications if(!notifications) { return; } let headers = new Headers({'Content-Type': 'application/json'}); headers.append('Authorization','Basic ' + btoa(this.username_decrypted + ':' + this.password_decrypted)); let body = this.formObj(tokens,title,action,Name); console.log(body); this.http.post("https://<some-url>",body,{ headers: headers } ).subscribe((responsE) => { console.log("httpS RESPONSE"); console.log(responsE); },function(error) { console.log("httpS ERROR"); console.log(error); }); }
标题响应如下:
response.setHeader("Access-Control-Allow-Origin","*"); response.setHeader("Access-Control-Allow-Methods","POST,GET,OPTIONS,deletE"); response.setHeader("Access-Control-Max-Age","3600"); response.setHeader("Access-Control-Allow-Headers","Origin,X-requested-With,Content-Type,Accept,Authorization");
并收到此错误:
{ "_body": {"isTrusted":truE},"status":0,"ok":false,"statusText":"","headers":{},"type":3,"url":null }
Spring Boot API:
@CrossOrigin @requestMapping(value="/notifications",method=requestMethod.POST,consumes=MediaType.APPLICATION_JSON_VALUE,produces=MediaType.APPLICATION_JSON_value) public ResponseEntity<NotificationParent> sendNotifications(@requestBody NotificationParent objs) { ... return new ResponseEntity<NotificationParent>(objs,httpStatus.OK); }
我假设它有iOS安全问题,但我不知道.
以上是大佬教程为你收集整理的api – HTTPS请求仅在iOS,Ionic 2上失败全部内容,希望文章能够帮你解决api – HTTPS请求仅在iOS,Ionic 2上失败所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。