Iphone emoji Unicode decode issue for push notification dispatch by APNs
<p>My web service publish push notification to APNs and APNs send to destination IOS device.
When apns contain Unicode emoji on alert body push notification and Iphone os can't decode my Unicode emoji '<strong>\uD83D\uDE0A</strong>' app already kill.</p>

<p>Push notification show same '<strong>\uD83D\uDE0A</strong>', No emoji shown on banner notification bar on top.</p>

<p><strong>Android application works fine by GCM dispatches push notification But IOS not support.</strong>
<em>Iphone-Ios supports only this format '<strong>\ue415</strong>'</em></p>

<p>Here code that from ActiveMQ subscribe chat payload get into web-service</p>

<pre><code>            public void onPublish(UTF8Buffer topic, Buffer msg, Runnable ack) {
            try {

                String body = msg.utf8().toString();
                if (logger.isInfoEnabled()) {
                    logger.info("MQTT connection.listener.onPublish(), msg Received ["
                            + body + "]");
                }
                if (body.contains("\"cmd\":\"chat\"")
                        &amp;&amp; body.contains("\"is_sender_msg\":true")) { 
                    QueueMgr.addToChatQueue(body); //Changed true to false
                }
                else if(body.contains("\"cmd\":\"msg_seen\"")){
                    QueueMgr.addToChatReadSeenQueue(body);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                ack.run();
            }
        }
</code></pre>

<p>My code for create push notification on java</p>

<pre><code>public static JSONObject constructePushJson(JSONObject jsonObject,String[] cloudkeyWithDevice) throws JSONException {
    if(cloudkeyWithDevice[0] != null){
        JSONObject pnAPIdata = new JSONObject();
            if(cloudkeyWithDevice[1].equals("a") || cloudkeyWithDevice[1].equals("d")){
                pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_CMD, com.anyorg.constants.AppConstants.CMD_ANDROID_PUSH);
            }
            else{
                pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_CMD, com.anyorg.constants.AppConstants.CMD_IOS_PUSH);
            }
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_APP_TOKEN, com.anyorg.constants.AppConstants.DEFAULT_APP_TOKEN);
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_DEVICE_TOKEN, cloudkeyWithDevice[0]);
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_USER_ID, jsonObject.getInt(com.anyorg.constants.AppConstants.FLD_TO_USER_ID));
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_DEVICE_ID, 0);
            String alertMsg=StringEscapeUtils.unescapeJava(jsonObject.getString(com.anyorg.constants.AppConstants.FLD_BODY));
            jsonObject.put(com.anyorg.constants.AppConstants.FLD_BODY,alertMsg);
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_ALERT_MSG, "AryaConnect: "+alertMsg);//(jsonObject.isNull("body")) ? jsonObject.getString("from_user_name")+": Sent a file" : jsonObject.getString("from_user_name")+": "+jsonObject.getString("body")
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_MSG, jsonObject);//jsonObject.getString(com.anyorg.constants.AppConstants.FLD_BODY)
            pnAPIdata.put(com.anyorg.constants.AppConstants.FLD_CALLBACK_URL, callbackUrl);
            pnAPIdata.put(com.anyorg.constants.AppConstants.MAC_ADDRESS_ID, jsonObject.getString("mobile_rec_id"));
            return pnAPIdata;
    }
    else{
        return null;
    }

}
</code></pre>

<p>Publish to APNs code</p>

<pre><code>public class ANSNotificationDispatcher implements NotificationDispatcher {
protected static final Logger logger = Logger
        .getLogger(ANSNotificationDispatcher.class);

public static final String OS_NAME = AppConstants.OS_TYPE_IPHONE;

String keystore;
String password;
boolean production;

public ANSNotificationDispatcher() {
    try {
        keystore = AppConfig.getAPNKeystore();
        password = AppConfig.getAPNKeystorePassword();
        PushyAPNMgr.init(keystore, password, AppConfig.isAPNProdcution());
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

private void push(Payload payload, String token, String userId,
        String deviceId) throws ConfigurationException,
        DeviceUnregisteredException {

    // QueueManager.addToIOsQueue(payLoad, token, userId, ivUserDeviceId);
    long stime = System.currentTimeMillis();
    try {
        PushyAPNMgr.push(token, payload.toString());
        if (logger.isInfoEnabled())
            logger.info("push(): APN PN userId [" + userId
                    + "], device id [" + deviceId + "] payoad [" + payload
                    + "] Response time ["
                    + (System.currentTimeMillis() - stime) + "]ms");
    } catch (Exception e) {
        e.printStackTrace();
        throw new ConfigurationException();
    }
}

public static Payload createComplexPayload(JSONObject jsonObject) {

    PushNotificationPayload complexPayload = null;
    try {
        complexPayload = createPayload(jsonObject);
        String msg = Common.getStringAsNull(jsonObject,
                AppConstants.FLD_MSG);
        if (!Common.isEmpty(msg)) {
            complexPayload.addCustomDictionary(AppConstants.FLD_MSG, msg);
        }
        if (logger.isInfoEnabled()) {
            logger.info("createComplexPayloadV2(): payload ["
                    + complexPayload.getPayload().toString() + "]");
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return complexPayload;
}

public void dispatch(JSONObject jsonObject, String jsonData)
        throws NotificationException, DeviceUnregisteredException,
        MultipleRegistartionIdException, ConfigurationException {

    String deviceToken = Common.getStringAsNull(jsonObject,
            AppConstants.FLD_DEVICE_TOKEN);
    if (Common.isEmpty(deviceToken)) {
        logger.error("dispatch(): device token is null, cmd [" + jsonData
                + "]");
        return;
    }
    Payload payload = createComplexPayload(jsonObject);

    String userId = Common.getStringAsNull(jsonObject,
            AppConstants.FLD_USER_ID);
    String deviceId = Common.getStringAsNull(jsonObject,
            AppConstants.FLD_DEVICE_ID);
    push(payload, deviceToken, userId, deviceId);
}

public static void handleInvalidTokeException(String token) {
}

public static void handleDeviceUnregisteredException(String token) {
}
</code></pre>

<p>}</p>

<p><a href="https://i.stack.imgur.com/Ldsp2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ldsp2.jpg" alt="Ios push notification managed by Ios OS "></a></p>

<h2>Ios push notification managed by Ios OS</h2>

<p>My Apache Catalina log
<a href="https://i.stack.imgur.com/Nn6zy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nn6zy.png" alt="Apache Catalina log"></a>
I am a web service cloud developer faceing this issue last one days for only Ios app. So please, if some body have knowledge or done before. please advise and refer me some idea.
Emoji in my push notifications link.
<a href="https://mixpanel.com/help/questions/articles/how-do-i-send-custom-parameters-like-emoji-in-my-push-notifications" rel="nofollow noreferrer">https://mixpanel.com/help/questions/articles/how-do-i-send-custom-parameters-like-emoji-in-my-push-notifications</a>
Thanks</p>