Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

By default WSO2 IoT Server has implement implemented 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.

...

  1. Implement the PushNotificationProvider interface by importing org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider.

    Info

    Make sure to export the dependency given below in your pom.xml file.

    Code Block
    <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.

    Code Block
    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);
     }
    }
  2. 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.

    Code Block
    <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>
  3. Configure your device type XML file to call the push notification provider when the server needs to communicate with the device. 
    For example, see how it was implemented for the notification provider of RaspberryPi.

    Code Block
    <PushNotificationProvider type="MQTT">
       <FileBasedProperties>true</FileBasedProperties>
    </PushNotificationProvider> 

...