Support incrementing push badge value by more than 1 (#4889)

* Support 'IncrementByN' badge value for higher push badge increments

* Fix test

* Rely on object for badge incrementation (i.e. {increment: 3}) rather than string (IncrementBy3)

* For badge incrementation, utilize format similar to other operation notation
This commit is contained in:
Ross Bayer
2018-07-12 11:34:08 -07:00
committed by Florent Vilmart
parent 800959f458
commit ced6b76ef5
3 changed files with 93 additions and 5 deletions

View File

@@ -2,10 +2,17 @@ import Parse from 'parse/node';
import deepcopy from 'deepcopy';
export function isPushIncrementing(body) {
return body.data &&
body.data.badge &&
typeof body.data.badge == 'string' &&
body.data.badge.toLowerCase() == "increment"
if (!body.data || !body.data.badge) {
return false;
}
const badge = body.data.badge;
if (typeof badge == 'string' && badge.toLowerCase() == "increment") {
return true;
}
return typeof badge == 'object' && typeof badge.__op == 'string' &&
badge.__op.toLowerCase() == "increment" && Number(badge.amount);
}
const localizableKeys = ['alert', 'title'];