是否有GCM registrationId模式? [英] Is there a GCM registrationId pattern?

查看:134
本文介绍了是否有GCM registrationId模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/**
 * @author Sebastien Lorber <i>(lorber.sebastien@gmail.com)</i>
 */
public enum EnumDeviceType {

    ANDROID {
        @Override
        public boolean validateDeviceIdentifier(String deviceIdentifier) {
            Preconditions.checkArgument( !Strings.isNullOrEmpty(deviceIdentifier) );
            return ANDROID_REGISTRATION_ID_PATTERN.matcher(deviceIdentifier).matches();
        }
    },
    IOS {
        @Override
        public boolean validateDeviceIdentifier(String deviceIdentifier) {
            Preconditions.checkArgument( !Strings.isNullOrEmpty(deviceIdentifier) );
            return IOS_DEVICE_TOKEN_PATTERN.matcher(deviceIdentifier).matches();
        }
    },
    ;

    // TODO how do we validate registration Ids
    public static final Pattern ANDROID_REGISTRATION_ID_PATTERN = Pattern.compile(".*");
    // IOS device token is a 64 HEX string
    public static final Pattern IOS_DEVICE_TOKEN_PATTERN = Pattern.compile("[a-fA-F0-9]{64,64}");


    public abstract boolean validateDeviceIdentifier(String deviceIdentifier);


    public boolean isIos() {
        return IOS.equals(this);
    }

    public boolean isAndroid() {
        return ANDROID.equals(this);
    }


}

是否有任何已知的图案为GCM registrationId我可以用它来验证应用程序的registrationId有一个正确的形状? 我只是想知道哪些字符它的范围,这是最低和最高为例大小......或任何其他资料...

Is there any known pattern for the GCM registrationId i can use to validate on application that the registrationId has a correct shape? I would just like to know which range of chars it has, which is the minimum and maximum size for exemple... or any other information...

推荐答案

该文件没有指定任何模式,因此任何有效的字符串是允许的。该格式可以在未来改变;请不要验证此输入对的任意的模式,因为这可能会导致您的应用程序,以打破,如果发生这种情况。

The documentation doesn't specify any pattern, therefore any valid string is allowed. The format may change in the future; please do not validate this input against any pattern, as this may cause your app to break if this happens.

如同registration_id字段,上界上的大小是最大尺寸的cookie,它是4K(4096字节)。

As with the "registration_id" field, the upper bound on size is the max size for a cookie, which is 4K (4096 bytes).

这篇关于是否有GCM registrationId模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆