By default WSO2 IoT Server has implement push notification providers for MQTT, XMPP, FCM, and APNS. This document will guide you on how to create a new push notification provider for your device type.
Follow the steps given below:
Implement the
PushNotificationProvider
interface by importingorg.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider
.Make sure to export the dependency given below in your
pom.xml
file.<dependency> <groupId>org.wso2.carbon.devicemgt</groupId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId> </dependency>
For example, see the sample implementation done for FCM notification provider.
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider; public class FCMBasedPushNotificationProvider implements PushNotificationProvider { private static final String PS_PROVIDER_FCM = "FCM"; @Override public String getType() { return PS_PROVIDER_FCM; } @Override public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) { return new FCMNotificationStrategy(config); } }
Configure the <IoT_HOME>/conf/cdm-config.xml file by adding the reference to your notification provider, under the
PushNotificationProviders
property.For example, see the configuration done for the FCM notification provider.
<PushNotificationProviders> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider</Provider> <!--<Provider>org.wso2.carbon.device.mgt.mobile.impl.ios.apns.APNSBasedPushNotificationProvider</Provider>--> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider> </PushNotificationProviders>
What's next?
For more information on how the notification provider is used, see Server Communicating with the Device.