cn.jpush.api.push.mode.PushPayload.IsiOSExceedLength C# (CSharp) Method

IsiOSExceedLength() public method

public IsiOSExceedLength ( ) : bool
return bool
        public bool IsiOSExceedLength()
        {
            int messageLength = 0;
            if (message != null)
            {
                var messageJson = JsonConvert.SerializeObject(this.message, jSetting);
                messageLength += UTF8Encoding.UTF8.GetBytes(messageJson).Length;
            }
            if (this.notification == null)
            {
                return messageLength > MAX_IOS_ENTITY_LENGTH;
            }
            else
            {
                var notificationJson = JsonConvert.SerializeObject(this.notification);
                if (notificationJson != null)
                {
                    int iosJsonLength = 0;
                    if (this.notification.IosNotification != null)
                    {
                        var iosJson = JsonConvert.SerializeObject(this.notification.IosNotification, jSetting);
                        if (iosJson != null)
                        {
                            iosJsonLength = UTF8Encoding.UTF8.GetBytes(iosJson).Length;
                        }
                    }
                    messageLength += UTF8Encoding.UTF8.GetBytes(notificationJson).Length;
                    messageLength -= iosJsonLength;
                }
                return messageLength > MAX_IOS_ENTITY_LENGTH;
            }
        }