Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
114 views
in Technique[技术] by (71.8m points)

java - Is there a GCM registrationId pattern?

/**
 * @author Sebastien Lorber <i>([email protected])</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);
    }


}

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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...