我想从我的SpringBoot API向我的应用程序发送推送通知。我尝试了这段代码,但它没有起作用。
@RestController
public class NotificationController {
ApnsService service =
APNS.newService()
.withCert("/Users/User/Documents/Personal_Projects/Api/src/main/resources/Certificates.p12", "a")
.withSandboxDestination()
.build();
String payload = APNS.newPayload()
.alertBody("My first notification\nHello, I'm push notification")
.sound("default")
.build();
service.push(merchantObject.getEmail(), payload);
System.out.println("The message has been hopefully sent...");
return new Response("", "Sent successfully");
}
代码返回成功响应,但我在我的应用程序上没有收到推送通知。代码中缺少什么?当我使用Firebase发送推送通知时,我可以在我的iPhone上收到通知。