Ich habe eine Ionic 2
Anwendung, die eine Spring Boot
API aufruft, um Push-Benachrichtigungen an andere Geräte zu senden. Die API ist mit HTTPS konfiguriert.HTTPS-Anfrage schlägt nur auf iOS, Ionic 2
Die API POST
Anfrage funktioniert auf alles außeriOS
.
Mein SSL-Zertifikat auf dem Server ist selbstsigniert (vielleicht ist das das?).
Werke auf:
- ionische dienen
- Android
- Postman
- curl
Hier ist die Anfrage:
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);
});
}
Die Header-Reaktionen sind wie folgt:
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");
Und dieser Fehler empfangen wird:
{
"_body":
{"isTrusted":true},
"status":0,"ok":false,
"statusText":"",
"headers":{},
"type":3,
"url":null
}
Frühling 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);
}
ich seine iOS Sicherheitslücke gehe davon aus, aber Ich habe keine Ahnung.
Versuchen Sie dies machen - http://uncaughterror.com/programming/ionic3/preflight- Antwort-Problem-mit-ionic3-app-on-ios-build-only-behoben/ –