File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 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 {
352352 [OneSignal.User removeSms: smsNumber];
353353}
354354
355- RCT_EXPORT_METHOD (addTag:(NSString *)key value:(NSString * )value) {
355+ RCT_EXPORT_METHOD (addTag:(NSString *)key value:(id )value) {
356356 [OneSignal.User addTagWithKey: key value: value];
357357}
358358
Original file line number Diff line number Diff line change @@ -433,11 +433,19 @@ export namespace OneSignal {
433433 export function addTag ( key : string , value : string ) {
434434 if ( ! isNativeModuleLoaded ( RNOneSignal ) ) return ;
435435
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' ) ;
438438 return ;
439439 }
440440
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+
441449 RNOneSignal . addTag ( key , value ) ;
442450 }
443451
@@ -456,6 +464,18 @@ export namespace OneSignal {
456464 return ;
457465 }
458466
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+
459479 RNOneSignal . addTags ( tags ) ;
460480 }
461481
You can’t perform that action at this time.
0 commit comments