Skip to content

Commit a5c767a

Browse files
committed
Refine tagging methods
- ensure consistency of string conversion methods - check for null or undefined values instead of falsy checks
1 parent 243d2d9 commit a5c767a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: src/index.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ export namespace OneSignal {
433433
export function addTag(key: string, value: string) {
434434
if (!isNativeModuleLoaded(RNOneSignal)) return;
435435

436-
if (!key || !value) {
437-
console.error('OneSignal: sendTag: must include a key and a value');
436+
if (!key || value === undefined || value === null) {
437+
console.error('OneSignal: addTag: must include a key and a value');
438438
return;
439439
}
440440

@@ -464,9 +464,7 @@ export namespace OneSignal {
464464
const convertedTags = tags as { [key: string]: any };
465465
Object.keys(tags).forEach(function (key) {
466466
// forces values to be string types
467-
if (typeof convertedTags[key] !== 'string') {
468-
convertedTags[key] = JSON.stringify(convertedTags[key]);
469-
}
467+
convertedTags[key] = String(convertedTags[key]);
470468
});
471469

472470
RNOneSignal.addTags(tags);

0 commit comments

Comments
 (0)