Skip to content

Commit 087efef

Browse files
committed
add more complex example for custom events
1 parent 70d188c commit 087efef

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

examples/RNOneSignalTS/OSButtons.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,19 @@ class OSButtons extends React.Component<Props> {
434434
const trackEventButton = renderButtonView('Track Event', () => {
435435
loggingFunction('Tracking event: ', 'ReactNative');
436436
const platform = Platform.OS; // This will be 'ios' or 'android'
437+
OneSignal.User.trackEvent(`ReactNative-${platform}-noprops`);
437438
OneSignal.User.trackEvent(`ReactNative-${platform}`, {
438-
DEF: '456',
439+
someNum: 123,
440+
someString: 'abc',
441+
someBool: true,
442+
someObject: {
443+
abc: '123',
444+
nested: {
445+
def: '456',
446+
},
447+
},
448+
someArray: [1, 2, 3],
449+
someNull: null,
439450
});
440451
});
441452

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ export namespace OneSignal {
613613
) {
614614
if (!isNativeModuleLoaded(RNOneSignal)) return;
615615

616-
if (!isObjectSerializable(properties)) {
617-
return console.error('Properties must be JSON-serializable');
616+
if (!isObjectSerializable(properties ?? {})) {
617+
console.error('Properties must be JSON-serializable');
618+
return;
618619
}
619620

620621
RNOneSignal.trackEvent(name, properties);

0 commit comments

Comments
 (0)