PLSQL APPLE push notifiactions

2019-06-07 23:27发布

问题:

I have a problem with notifications. I'm using Oracle apex with rest services.

How to send push notifications to APN iphone from pl/sql? Are you using Java in database?

回答1:

We successfully implemented the solution in our java code with java-apns

You create a service:

InputStream resourceAsStream = Thread
    .currentThread()
    .getContextClassLoader()
    .getResourceAsStream("Certificate.p12");

ApnsService service = APNS.newService()
    .withCert(resourceAsStream, "CERTNAME")
    .withProductionDestination()
    .build();

Then you create a payload:

String payload = APNS.newPayload()
    .sound("default")
    .alertBody(generatePushMessageBody(...))
    .customField("title", generateTitleForPushMessage(user))
    .customField("startDate", formatDateForPushMessage(...)
    .customField("username", user.getUserName())
    .build();

And then send the push notification:

service.push(registrationId, payload);

You need to put this code to a PL/SQL stored procedure and it will work.