Apache camel 使用apache camel apns组件编写一个简单的代码来向iOS设备发送通知?
我不熟悉camel和stackoverflow,我用JavaDSL编写了一个简单的代码来向iOS设备发送通知。 这是我的密码:Apache camel 使用apache camel apns组件编写一个简单的代码来向iOS设备发送通知?,apache-camel,Apache Camel,我不熟悉camel和stackoverflow,我用JavaDSL编写了一个简单的代码来向iOS设备发送通知。 这是我的密码: public class ApplePush{ protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = new DefaultCamelContext(); ApnsServiceFactory apnsServiceFa
public class ApplePush{
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = new DefaultCamelContext();
ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory();
apnsServiceFactory.setCertificatePath("classpath"); //Specify the certificate path
apnsServiceFactory.setCertificatePassword("password"); //Specify the password
ApnsService apnsService = apnsServiceFactory.getApnsService();
ApnsComponent apnsComponent = new ApnsComponent(apnsService);
camelContext.addComponent("apns", apnsComponent);
return camelContext;
}
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:test")
.to("apns:notify?tokens=" + ""/*IOS_DEVICE_TOKEN* put device token here*/);
}
};
}
public static void main(String args[]) throws Exception{
ApplePush ob = new ApplePush();
String message = "Hello World";
CamelContext component = ob.createCamelContext();
component.addRoutes(ob.createRouteBuilder());
ProducerTemplate template = component.createProducerTemplate();
component.start();
template.sendBody("direct:test", message);
Thread.sleep(1000);
component.stop();
}
}
此代码是否与适当的证书和设备令牌一起工作,或者我是否做错了什么???您是否尝试过运行它?我觉得没问题,我还没试过。我现在没有iOS设备要测试。所以,我问它是否有效。谢谢你的回答。我还有一个疑问,在我们使用了apns组件网页上给出的apns:消费者到模拟:结果的反馈后,如何获取非活动设备的列表。