/**
         * 收到消息<br>
         *
         * @param context
         *            APP上下文对象
         * @param message
         *            收到的消息
         */

        public override void OnTextMessage(Context context, XGPushTextMessage message)
        {
            if (context == null || message == null)
            {
                return;
            }
            String text = "收到消息:" + message.ToString();
            // 获取自定义key-value
            String customContent = message.CustomContent;

            if (!string.IsNullOrEmpty(customContent))
            {
                try
                {
                    JSONObject obj = new JSONObject(customContent);
                    // key1为前台配置的key
                    if (!obj.IsNull("key"))
                    {
                        String value = obj.GetString("key");
                        Log.Debug(LogTag, "get custom value:" + value);
                    }
                    // ...
                }
                catch (JSONException e)
                {
                    e.PrintStackTrace();
                }
            }
            // APP自主处理消息的过程。。。
            Log.Debug(LogTag, text);
            show(context, text);
        }
Пример #2
0
        public override void OnTextMessage(Context context, XGPushTextMessage message)
        {
            string customContent = message.CustomContent;

            if (customContent != null && customContent.Length != 0)
            {
                MessagingService.Current.SendMessage(MessageKeys.NavigateNotification, customContent);
            }
        }