File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
352
352
[OneSignal.User removeSms: smsNumber];
353
353
}
354
354
355
- RCT_EXPORT_METHOD (addTag:(NSString *)key value:(NSString * )value) {
355
+ RCT_EXPORT_METHOD (addTag:(NSString *)key value:(id )value) {
356
356
[OneSignal.User addTagWithKey: key value: value];
357
357
}
358
358
Original file line number Diff line number Diff line change @@ -433,11 +433,19 @@ export namespace OneSignal {
433
433
export function addTag ( key : string , value : string ) {
434
434
if ( ! isNativeModuleLoaded ( RNOneSignal ) ) return ;
435
435
436
- if ( ! key || ( ! value && 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' ) ;
438
438
return ;
439
439
}
440
440
441
+ // forces values to be string types
442
+ if ( typeof value !== 'string' ) {
443
+ console . warn (
444
+ 'OneSignal: addTag: tag value must be of type string; attempting to convert' ,
445
+ ) ;
446
+ value = String ( value ) ;
447
+ }
448
+
441
449
RNOneSignal . addTag ( key , value ) ;
442
450
}
443
451
@@ -456,6 +464,18 @@ export namespace OneSignal {
456
464
return ;
457
465
}
458
466
467
+ const convertedTags = tags as { [ key : string ] : any } ;
468
+ Object . keys ( tags ) . forEach ( function ( key ) {
469
+ if ( typeof convertedTags [ key ] !== 'string' ) {
470
+ console . warn (
471
+ 'OneSignal: addTags: tag value for key ' +
472
+ key +
473
+ ' must be of type string; attempting to convert' ,
474
+ ) ;
475
+ convertedTags [ key ] = String ( convertedTags [ key ] ) ;
476
+ }
477
+ } ) ;
478
+
459
479
RNOneSignal . addTags ( tags ) ;
460
480
}
461
481
You can’t perform that action at this time.
0 commit comments