Push Notification Web Service

    Xtify has created the first push notification service for Android – enabling developers to push messages directly to their users using a simple web service

    Adding push notifications to your mobile service has never been easier - integrate the Xtify SDK with your application and create a new channel to reach your users anytime.

    Follow the instructions below to push messages directly to the Xtify Android SDK regardless of the user's location.  

    For more information about message structure, read the below and reference "Step 3" on the How to Structure a Campaign page. 

    Overview

    The notification web service can accept the following values in the content:

        appId = [[YOUR APP KEY]]

        userKey = [[YOUR USER'S USERKEY]]

        actionType = must be one of LAUNCH_APP, URL, or CUSTOM

        showNotificationScreen = true|false (used only if actionType is CUSTOM)

        collectPollingData = true|false (used only if actionType is CUSTOM and showNotificationScreen is true)

        notificationUrl = URL to open in browser (used only if actionType is URL)

        notificationTitle = Title to be displayed

        notificationBody = Content to be displayed

        notificationLinkLabel = Label of link when the notification screen is shown (used only if actionType is URL  or  actionType is CUSTOM and actionIntent is empty)

        actionIntent = [[android action intent]] (used only if actionType is CUSTOM)

        actionCategories = [[categories passed to intent]] (used only if actionType is CUSTOM)

        actionData = [[data passed to intent]] (plain text, not an xml tree, must be XML and URI encoded, used only if actionType is CUSTOM)

     
    Message should be wrapped in 'sdk-notification' like this:

    <?xml version="1.0" encoding="UTF-8"?>

    <sdk-notification>

        <actionType>CUSTOM</actionType>

        <appId>YOUR_API_KEY_GOES_HERE</appId>

        <userKey>YOUR_USER_KEY_GOES_HERE</userKey>

        <showNotificationScreen>false</showNotificationScreen>

        <notificationTitle>test subject</notificationTitle>

        <notificationBody>test body</notificationBody>

        <actionIntent>com.example.LAUNCH</actionIntent> 

        <actionCategories>android.intent.category.DEFAULT</actionCategories> 

    </sdk-notification>

     

    Call the web service with a HTTP 'PUT' or 'POST' with content type 'application/xml'.  You will receive a response with the following content:

    <sdk-notification-response>

       <response>SUCCESS|ERROR</response>

       <message>[[Error message if ERROR response]]</message>

       <notificationId>[[ID of message for reporting and tracking if SUCCESS response]]</notificationId>

    </sdk-notification-response>

     

    Sample Code

    Below is an example Java program for accessing the Notification Web Service:

    import java.io.BufferedReader;

    import java.io.IOException;

    import java.io.InputStreamReader;

    import java.io.OutputStream;

    import java.net.HttpURLConnection;

    import java.net.MalformedURLException;

    import java.net.URL;

     

    public class Main {

     

        public static void main(String args[]) throws IOException {

            String urlString = "http://notify.xtify.com/api/1.0/SdkNotification";

            String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + 

                    "<sdk-notification>" +

                    "<actionType>LAUNCH_APP</actionType>" +

                    "<appId>[[YOUR APP KEY]]</appId>" +

                    "<userKey>[[YOUR USER'S USERKEY]]</userKey>" +

                    "<notificationBody>Test Web Service Notification</notificationBody>" +

                    "<notificationTitle>Test Web Service Notification</notificationTitle>" +

                    "</sdk-notification>";

            String result = null;

            URL url = null;

            try {

                url = new URL(urlString);

            } catch (MalformedURLException e) {

                System.out.println(e.getMessage());

            }

     

            HttpURLConnection urlConn = null;

            OutputStream out = null;

            BufferedReader in = null;

            if (url != null) {

                try {

                    urlConn = (HttpURLConnection) url.openConnection();

                    urlConn.addRequestProperty("Content-Type","application/xml");

     

                    urlConn.setRequestMethod("PUT");

                    urlConn.setDoOutput(true);

                    urlConn.setDoInput(true);

                    urlConn.connect();

     

                    // Write content data to server

                    out = urlConn.getOutputStream();

                    out.write(content.getBytes());

                    out.flush();

     

                    // Check response code

                    if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {

     

                        in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()), 8192);

                        StringBuffer strBuff = new StringBuffer();

                        String inputLine;

     

                        while ((inputLine = in.readLine()) != null) {

                            strBuff.append(inputLine);

                        }

                        result = strBuff.toString();

     

                        System.err.println(result);

     

                    }

     

                } catch (IOException e) {

                    System.out.println(e.getMessage());

                } finally {

                    if (in != null) {

                        in.close();

                    }

                    if (out != null) {

                        out.close();

                    }

                    if (urlConn != null) {

                        urlConn.disconnect();

                    }

                }

            }

        }

    }

     

    Notification Limits

    The Xtify Push Notification Web Service is free!  Check your package details for more information when you create your Xtify API key.  Contact support@xtify.com with questions.
     

Print

See Xtify Push Demo!!!


A (relatively) short demonstration of the Xtify platform from the Motodev booth at CTIA.

Click HERE FOR VIDEO now!

Powered by Olark