Custom SMS MMS Implementation
Prerequisites
The bundles open-xchange-messaging-sms and open-xchange-messaging-sms-gui should be installed
Implementation
The basic implementation must be done by a class implementing the interface com.openexchange.messaging.sms.service.MessagingNewService
. This implementing class must be annouced to OSGi as a service implementation for this class. This can be done be the following:
context.registerService(MessagingNewService.class.getName(), new OwnImpl(), null);
In this example the new class OwnImpl
must be written. Inside this class the interface enforces that an object of the type MessagingUserConfigurationInterface
and an object of the type MessagingAccountTransport
must be returned in the corresponding methods.
Please note that each of the returned objects is only valid for one session. So the returned MessagingUserConfigurationInterface
can provide user specific settings based on the values in the session object.
The settings which can be adjusted in the configuration should be explained by the JavaDoc Links below.
The more important part is the returned MessagingAccountTransport
where the method com.openexchange.messaging.MessagingAccountTransport.transport(MessagingMessage, Collection<MessagingAddressHeader>) is responsible for sending the SMS / MMS. The corresponding MessagingMessage
object therefore provides all the needed data for composing the messages. The same applies for the Collection<MessagingAddressHeader>
is irrelevant in this case
Please pay attention to the way how the sender and the receiver are fetched from the message object as this might be uncommon. The correct way to do it is:
final MessagingHeader to = message.getFirstHeader(MessagingHeader.KnownHeader.TO.toString()); final MessagingHeader from = message.getFirstHeader(MessagingHeader.KnownHeader.FROM.toString());
The plain string is available through the getValue()
method on the MessagingHeader