Skip to content

Commit 20cbac7

Browse files
committed
add track event demo
1 parent df149f3 commit 20cbac7

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ coverage/
1010
# tsc
1111
#
1212
dist
13+
android/build
1314

1415
# OSX
1516
#

android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ of this software and associated documentation files (the "Software"), to deal
3838
import java.util.HashMap;
3939
import java.util.Map;
4040

41-
import javax.naming.Context;
41+
import android.content.Context;
4242

4343
import org.jetbrains.annotations.Nullable;
4444
import org.json.JSONException;

examples/RNOneSignalTS/OSButtons.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
2+
import { Platform, StyleSheet, Text, View } from 'react-native';
33
import { OneSignal } from 'react-native-onesignal';
44
import { renderButtonView } from './Helpers';
55
// Remove: import {Text, Divider} from '@react-native-material/core';
@@ -431,11 +431,20 @@ class OSButtons extends React.Component<Props> {
431431
},
432432
);
433433

434+
const trackEventButton = renderButtonView('Track Event', () => {
435+
loggingFunction('Tracking event: ', 'ReactNative');
436+
const platform = Platform.OS; // This will be 'ios' or 'android'
437+
OneSignal.User.trackEvent(`ReactNative-${platform}`, {
438+
SomeProperty: 'SomeValue',
439+
});
440+
});
441+
434442
return [
435443
loginButton,
436444
logoutButton,
437445
addEmailButton,
438446
removeEmailButton,
447+
trackEventButton,
439448
sendTagWithKeyButton,
440449
deleteTagWithKeyButton,
441450
addTagsButton,

examples/RNOneSignalTS/android/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ hermesEnabled=true
4242
# This allows your app to draw behind system bars for an immersive UI.
4343
# Note: Only works with ReactActivity and should not be used with custom Activity.
4444
edgeToEdgeEnabled=false
45+
46+
# Node.js executable for React Native codegen
47+
# Ensure Node.js is in PATH when running Gradle builds
48+
# If using nvm, run: source ~/.nvm/nvm.sh && nvm use before building
49+
react.nodeExecutableAndArgs=node

0 commit comments

Comments
 (0)