Skip to content

Commit 69f0473

Browse files
committed
tweak demo example
1 parent 84fb50b commit 69f0473

File tree

4 files changed

+62
-51
lines changed

4 files changed

+62
-51
lines changed

examples/RNOneSignalTS/OSDemo.tsx

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { useFocusEffect } from '@react-navigation/native';
22
import React, { useCallback, useEffect, useState } from 'react';
33
import {
4-
Alert,
54
ScrollView,
65
StyleSheet,
76
Text,
87
TextInput,
98
TouchableOpacity,
109
View,
1110
} from 'react-native';
12-
import { LogLevel, OneSignal } from 'react-native-onesignal';
11+
import {
12+
LogLevel,
13+
NotificationClickEvent,
14+
NotificationWillDisplayEvent,
15+
OneSignal,
16+
} from 'react-native-onesignal';
1317
import { SafeAreaView } from 'react-native-safe-area-context';
1418
import OSButtons from './OSButtons';
1519
import OSConsole from './OSConsole';
@@ -37,44 +41,51 @@ const OSDemo: React.FC = () => {
3741
}, []);
3842

3943
const onForegroundWillDisplay = useCallback(
40-
(event: unknown) => {
41-
OSLog('OneSignal: notification will show in foreground:', event);
42-
const notif = (
43-
event as { getNotification: () => { title: string } }
44-
).getNotification();
44+
(event: NotificationWillDisplayEvent) => {
45+
const notif = event.getNotification();
46+
OSLog('OneSignal: notification will show in foreground:', notif.title);
47+
console.log('Will display notification event:', notif);
4548

46-
const cancelButton = {
47-
text: 'Cancel',
48-
onPress: () => {
49-
(event as { preventDefault: () => void }).preventDefault();
50-
},
51-
style: 'cancel' as const,
52-
};
49+
event.preventDefault();
5350

54-
const completeButton = {
55-
text: 'Display',
56-
onPress: () => {
57-
(event as { getNotification: () => { display: () => void } })
58-
.getNotification()
59-
.display();
60-
},
61-
};
51+
setTimeout(() => {
52+
notif.display();
53+
}, 5000);
6254

63-
Alert.alert(
64-
'Display notification?',
65-
notif.title,
66-
[cancelButton, completeButton],
67-
{
68-
cancelable: true,
69-
},
70-
);
55+
// const cancelButton = {
56+
// text: 'Cancel',
57+
// onPress: () => {
58+
// (event as { preventDefault: () => void }).preventDefault();
59+
// },
60+
// style: 'cancel' as const,
61+
// };
62+
63+
// const completeButton = {
64+
// text: 'Display',
65+
// onPress: () => {
66+
// (event as { getNotification: () => { display: () => void } })
67+
// .getNotification()
68+
// .display();
69+
// },
70+
// };
71+
72+
// Alert.alert(
73+
// 'Display notification?',
74+
// notif.title,
75+
// [cancelButton, completeButton],
76+
// {
77+
// cancelable: true,
78+
// },
79+
// );
7180
},
7281
[OSLog],
7382
);
7483

7584
const onNotificationClick = useCallback(
76-
(event: unknown) => {
77-
OSLog('OneSignal: notification clicked:', event);
85+
(event: NotificationClickEvent) => {
86+
const notif = event.notification;
87+
OSLog('OneSignal: notification clicked:', notif.title);
88+
console.log('Notification clicked event:', notif);
7889
},
7990
[OSLog],
8091
);

examples/RNOneSignalTS/ios/Podfile.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,48 @@ PODS:
88
- hermes-engine (0.82.1):
99
- hermes-engine/Pre-built (= 0.82.1)
1010
- hermes-engine/Pre-built (0.82.1)
11-
- OneSignalXCFramework (5.2.15):
12-
- OneSignalXCFramework/OneSignalComplete (= 5.2.15)
13-
- OneSignalXCFramework/OneSignal (5.2.15):
11+
- OneSignalXCFramework (5.2.16):
12+
- OneSignalXCFramework/OneSignalComplete (= 5.2.16)
13+
- OneSignalXCFramework/OneSignal (5.2.16):
1414
- OneSignalXCFramework/OneSignalCore
1515
- OneSignalXCFramework/OneSignalExtension
1616
- OneSignalXCFramework/OneSignalLiveActivities
1717
- OneSignalXCFramework/OneSignalNotifications
1818
- OneSignalXCFramework/OneSignalOSCore
1919
- OneSignalXCFramework/OneSignalOutcomes
2020
- OneSignalXCFramework/OneSignalUser
21-
- OneSignalXCFramework/OneSignalComplete (5.2.15):
21+
- OneSignalXCFramework/OneSignalComplete (5.2.16):
2222
- OneSignalXCFramework/OneSignal
2323
- OneSignalXCFramework/OneSignalInAppMessages
2424
- OneSignalXCFramework/OneSignalLocation
25-
- OneSignalXCFramework/OneSignalCore (5.2.15)
26-
- OneSignalXCFramework/OneSignalExtension (5.2.15):
25+
- OneSignalXCFramework/OneSignalCore (5.2.16)
26+
- OneSignalXCFramework/OneSignalExtension (5.2.16):
2727
- OneSignalXCFramework/OneSignalCore
2828
- OneSignalXCFramework/OneSignalOutcomes
29-
- OneSignalXCFramework/OneSignalInAppMessages (5.2.15):
29+
- OneSignalXCFramework/OneSignalInAppMessages (5.2.16):
3030
- OneSignalXCFramework/OneSignalCore
3131
- OneSignalXCFramework/OneSignalNotifications
3232
- OneSignalXCFramework/OneSignalOSCore
3333
- OneSignalXCFramework/OneSignalOutcomes
3434
- OneSignalXCFramework/OneSignalUser
35-
- OneSignalXCFramework/OneSignalLiveActivities (5.2.15):
35+
- OneSignalXCFramework/OneSignalLiveActivities (5.2.16):
3636
- OneSignalXCFramework/OneSignalCore
3737
- OneSignalXCFramework/OneSignalOSCore
3838
- OneSignalXCFramework/OneSignalUser
39-
- OneSignalXCFramework/OneSignalLocation (5.2.15):
39+
- OneSignalXCFramework/OneSignalLocation (5.2.16):
4040
- OneSignalXCFramework/OneSignalCore
4141
- OneSignalXCFramework/OneSignalNotifications
4242
- OneSignalXCFramework/OneSignalOSCore
4343
- OneSignalXCFramework/OneSignalUser
44-
- OneSignalXCFramework/OneSignalNotifications (5.2.15):
44+
- OneSignalXCFramework/OneSignalNotifications (5.2.16):
4545
- OneSignalXCFramework/OneSignalCore
4646
- OneSignalXCFramework/OneSignalExtension
4747
- OneSignalXCFramework/OneSignalOutcomes
48-
- OneSignalXCFramework/OneSignalOSCore (5.2.15):
48+
- OneSignalXCFramework/OneSignalOSCore (5.2.16):
4949
- OneSignalXCFramework/OneSignalCore
50-
- OneSignalXCFramework/OneSignalOutcomes (5.2.15):
50+
- OneSignalXCFramework/OneSignalOutcomes (5.2.16):
5151
- OneSignalXCFramework/OneSignalCore
52-
- OneSignalXCFramework/OneSignalUser (5.2.15):
52+
- OneSignalXCFramework/OneSignalUser (5.2.16):
5353
- OneSignalXCFramework/OneSignalCore
5454
- OneSignalXCFramework/OneSignalNotifications
5555
- OneSignalXCFramework/OneSignalOSCore
@@ -1828,8 +1828,8 @@ PODS:
18281828
- React-RCTFBReactNativeSpec
18291829
- ReactCommon/turbomodule/core
18301830
- SocketRocket
1831-
- react-native-onesignal (5.2.16):
1832-
- OneSignalXCFramework (= 5.2.15)
1831+
- react-native-onesignal (5.2.17):
1832+
- OneSignalXCFramework (= 5.2.16)
18331833
- React (< 1.0.0, >= 0.13.0)
18341834
- react-native-safe-area-context (5.6.2):
18351835
- boost
@@ -2768,7 +2768,7 @@ SPEC CHECKSUMS:
27682768
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
27692769
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
27702770
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
2771-
OneSignalXCFramework: ea9e14a95b92ad48d9b35037cbae88a9542bdea3
2771+
OneSignalXCFramework: 8ed6648481bee0bd973a138fecd80331b798524f
27722772
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
27732773
RCTDeprecation: f17e2ebc07876ca9ab8eb6e4b0a4e4647497ae3a
27742774
RCTRequired: e2c574c1b45231f7efb0834936bd609d75072b63
@@ -2802,7 +2802,7 @@ SPEC CHECKSUMS:
28022802
React-logger: 500f2fa5697d224e63c33d913c8a4765319e19bf
28032803
React-Mapbuffer: 06d59c448da7e34eb05b3fb2189e12f6a30fec57
28042804
React-microtasksnativemodule: d1ee999dc9052e23f6488b730fa2d383a4ea40e5
2805-
react-native-onesignal: 1634e96223d6a666b76f38f4a20fec6c87bbb0c4
2805+
react-native-onesignal: 3b6cd199ec0db87166ef7fb595715627a35b3244
28062806
react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460
28072807
React-NativeModulesApple: 46690a0fe94ec28fc6fc686ec797b911d251ded0
28082808
React-oscompat: 95875e81f5d4b3c7b2c888d5bd2c9d83450d8bdb

examples/RNOneSignalTS/ios/RNOneSignalTS.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
);
283283
runOnlyForDeploymentPostprocessing = 0;
284284
shellPath = /bin/sh;
285-
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
285+
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"\\\"$WITH_ENVIRONMENT\\\" \\\"$REACT_NATIVE_XCODE\\\"\"\n";
286286
};
287287
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
288288
isa = PBXShellScriptBuildPhase;

examples/RNOneSignalTS/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ bun pm pack
99
mv react-native-onesignal-*.tgz react-native-onesignal.tgz
1010

1111
# Use fresh install of the package
12-
cd $ORIGINAL_DIR
12+
cd "$ORIGINAL_DIR"
1313
bun pm cache rm
1414
bun i

0 commit comments

Comments
 (0)