Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. APNS
Apns Component Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Available as of Camel 2.8
The apns component is used for sending notifications to iOS devices. The apns components use javapns library. The component supports sending notifications to Apple Push Notification Servers (APNS) and consuming feedback from the servers.
The consumer is configured with 3600 seconds for polling by default because it is a best practice to consume feedback stream from Apple Push Notification Servers only from time to time. For example: every 1 hour to avoid flooding the servers.
The feedback stream gives informations about inactive devices. You only need to get this informations every some hours if your mobile application is not a heavily used one.
Maven users will need to add the following dependency to their
pom.xml
for this component:
URI format Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
To send notifications:
apns:notify[?options]
apns:notify[?options]
To consume feedback:
apns:consumer[?options]
apns:consumer[?options]
Options Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Producer Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Property | Default | Description |
---|---|---|
tokens
|
Empty by default. Configure this property in case you want to statically declare tokens related to devices you want to notify. Tokens are separated by comma. |
Consumer Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Property | Default | Description |
---|---|---|
delay
|
3600
|
Delay in seconds between each poll. |
initialDelay
|
10
|
Seconds before polling starts. |
timeUnit
|
SECONDS
|
Time Unit for polling. |
userFixedDelay
|
true
|
If true , use fixed delay between pools, otherwise fixed rate is used. See ScheduledExecutorService in JDK for details.
|
You can append query options to the URI in the following format,
?option=value&option=value&...
Exchange data format Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
When Camel will fetch feedback data corresponding to inactive devices, it will retrieve a List of InactiveDevice objects. Each InactiveDevice object of the retrieved list will be setted as the In body, and then processed by the consumer endpoint.
Message Headers Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Camel Apns uses these headers.
Property | Default | Description |
---|---|---|
CamelApnsTokens
|
Empty by default. | |
CamelApnsMessageType
|
STRING, PAYLOAD
|
In case you choose PAYLOAD for the message type, then the message will be considered as a APNS payload and sent as is. In case you choose STRING, message will be converted as a APNS payload |
Samples Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Camel Xml route Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Camel Java route Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
Create camel context and declare apns component programmatically Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
ApnsProducer - iOS target device dynamically configured via header: "CamelApnsTokens" Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
ApnsProducer - iOS target device statically configured via uri Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
ApnsConsumer Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
from("apns:consumer?initialDelay=10&delay=3600&timeUnit=SECONDS") .to("log:com.apache.camel.component.apns?showAll=true&multiline=true") .to("mock:result");
from("apns:consumer?initialDelay=10&delay=3600&timeUnit=SECONDS")
.to("log:com.apache.camel.component.apns?showAll=true&multiline=true")
.to("mock:result");
See Also Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!