Support for receiving "canonical id" update events from pushserver.

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-03-24 10:47:45 -07:00
parent 456164fc24
commit e69e395b25
2 changed files with 14 additions and 1 deletions

View File

@ -11,6 +11,9 @@ public class UnregisteredEvent {
@NotEmpty @NotEmpty
private String registrationId; private String registrationId;
@JsonProperty
private String canonicalId;
@JsonProperty @JsonProperty
@NotEmpty @NotEmpty
private String number; private String number;
@ -26,6 +29,10 @@ public class UnregisteredEvent {
return registrationId; return registrationId;
} }
public String getCanonicalId() {
return canonicalId;
}
public String getNumber() { public String getNumber() {
return number; return number;
} }

View File

@ -76,7 +76,13 @@ public class FeedbackHandler implements Managed, Runnable {
event.getTimestamp() > device.get().getPushTimestamp()) event.getTimestamp() > device.get().getPushTimestamp())
{ {
logger.info("GCM Unregister Timestamp matches!"); logger.info("GCM Unregister Timestamp matches!");
if (event.getCanonicalId() != null && !event.getCanonicalId().isEmpty()) {
logger.info("It's a canonical ID update...");
device.get().setGcmId(event.getCanonicalId());
} else {
device.get().setGcmId(null); device.get().setGcmId(null);
}
accountsManager.update(account.get()); accountsManager.update(account.get());
} }
} }