1- import React , { useEffect } from 'react' ;
2- import { View , Text , StyleSheet , StatusBar } from 'react-native' ;
3- import Svg , { Path } from 'react-native-svg' ;
41import { NavigationContainer } from '@react-navigation/native' ;
52import { createNativeStackNavigator } from '@react-navigation/native-stack' ;
6- import { SafeAreaProvider } from 'react-native-safe-area-context ' ;
7- import Toast from 'react-native-toast-message ' ;
3+ import React , { useEffect } from 'react' ;
4+ import { StatusBar , StyleSheet , Text , View } from 'react-native' ;
85import {
9- OneSignal ,
10- LogLevel ,
116 InAppMessageClickEvent ,
12- InAppMessageWillDisplayEvent ,
7+ InAppMessageDidDismissEvent ,
138 InAppMessageDidDisplayEvent ,
149 InAppMessageWillDismissEvent ,
15- InAppMessageDidDismissEvent ,
10+ InAppMessageWillDisplayEvent ,
11+ LogLevel ,
1612 NotificationClickEvent ,
1713 NotificationWillDisplayEvent ,
14+ OneSignal ,
1815} from 'react-native-onesignal' ;
16+ import { SafeAreaProvider } from 'react-native-safe-area-context' ;
17+ import Svg , { Path } from 'react-native-svg' ;
18+ import Toast from 'react-native-toast-message' ;
1919
2020import { AppContextProvider } from './src/context/AppContext' ;
2121import HomeScreen from './src/screens/HomeScreen' ;
2222import SecondaryScreen from './src/screens/SecondaryScreen' ;
23- import PreferencesService from './src/services/PreferencesService ' ;
23+ import LogManager from './src/services/LogManager ' ;
2424import OneSignalApiService from './src/services/OneSignalApiService' ;
25+ import PreferencesService from './src/services/PreferencesService' ;
2526import TooltipHelper from './src/services/TooltipHelper' ;
26- import LogManager from './src/services/LogManager' ;
2727import { Colors } from './src/theme' ;
2828
2929const Stack = createNativeStackNavigator ( ) ;
@@ -35,14 +35,19 @@ function App() {
3535 const init = async ( ) => {
3636 try {
3737 const prefs = PreferencesService . getInstance ( ) ;
38- const [ appId , consentRequired , privacyConsent , iamPaused , locationShared ] =
39- await Promise . all ( [
40- prefs . getAppId ( ) ,
41- prefs . getConsentRequired ( ) ,
42- prefs . getPrivacyConsent ( ) ,
43- prefs . getIamPaused ( ) ,
44- prefs . getLocationShared ( ) ,
45- ] ) ;
38+ const [
39+ appId ,
40+ consentRequired ,
41+ privacyConsent ,
42+ iamPaused ,
43+ locationShared ,
44+ ] = await Promise . all ( [
45+ prefs . getAppId ( ) ,
46+ prefs . getConsentRequired ( ) ,
47+ prefs . getPrivacyConsent ( ) ,
48+ prefs . getIamPaused ( ) ,
49+ prefs . getLocationShared ( ) ,
50+ ] ) ;
4651
4752 OneSignalApiService . getInstance ( ) . setAppId ( appId ) ;
4853
@@ -55,32 +60,61 @@ function App() {
5560 OneSignal . Location . setShared ( locationShared ) ;
5661
5762 // Register SDK event listeners for logging
58- OneSignal . InAppMessages . addEventListener ( 'willDisplay' , ( e : InAppMessageWillDisplayEvent ) => {
59- log . i ( TAG , `IAM willDisplay: ${ e . message . messageId } ` ) ;
60- } ) ;
61- OneSignal . InAppMessages . addEventListener ( 'didDisplay' , ( e : InAppMessageDidDisplayEvent ) => {
62- log . i ( TAG , `IAM didDisplay: ${ e . message . messageId } ` ) ;
63- } ) ;
64- OneSignal . InAppMessages . addEventListener ( 'willDismiss' , ( e : InAppMessageWillDismissEvent ) => {
65- log . i ( TAG , `IAM willDismiss: ${ e . message . messageId } ` ) ;
66- } ) ;
67- OneSignal . InAppMessages . addEventListener ( 'didDismiss' , ( e : InAppMessageDidDismissEvent ) => {
68- log . i ( TAG , `IAM didDismiss: ${ e . message . messageId } ` ) ;
69- } ) ;
70- OneSignal . InAppMessages . addEventListener ( 'click' , ( e : InAppMessageClickEvent ) => {
71- log . i ( TAG , `IAM click: ${ e . result . actionId ?? 'unknown' } ` ) ;
72- } ) ;
73- OneSignal . Notifications . addEventListener ( 'click' , ( e : NotificationClickEvent ) => {
74- log . i ( TAG , `Notification click: ${ e . notification . title ?? '' } ` ) ;
75- } ) ;
76- OneSignal . Notifications . addEventListener ( 'permissionChange' , ( granted : boolean ) => {
77- log . i ( TAG , `Permission changed: ${ granted } ` ) ;
78- } ) ;
79- OneSignal . Notifications . addEventListener ( 'foregroundWillDisplay' , ( e : NotificationWillDisplayEvent ) => {
80- log . i ( TAG , `Notification foregroundWillDisplay: ${ e . getNotification ( ) . title ?? '' } ` ) ;
81- e . preventDefault ( ) ;
82- e . getNotification ( ) . display ( ) ;
83- } ) ;
63+ OneSignal . InAppMessages . addEventListener (
64+ 'willDisplay' ,
65+ ( e : InAppMessageWillDisplayEvent ) => {
66+ log . i ( TAG , `IAM willDisplay: ${ e . message . messageId } ` ) ;
67+ } ,
68+ ) ;
69+ OneSignal . InAppMessages . addEventListener (
70+ 'didDisplay' ,
71+ ( e : InAppMessageDidDisplayEvent ) => {
72+ log . i ( TAG , `IAM didDisplay: ${ e . message . messageId } ` ) ;
73+ } ,
74+ ) ;
75+ OneSignal . InAppMessages . addEventListener (
76+ 'willDismiss' ,
77+ ( e : InAppMessageWillDismissEvent ) => {
78+ log . i ( TAG , `IAM willDismiss: ${ e . message . messageId } ` ) ;
79+ } ,
80+ ) ;
81+ OneSignal . InAppMessages . addEventListener (
82+ 'didDismiss' ,
83+ ( e : InAppMessageDidDismissEvent ) => {
84+ log . i ( TAG , `IAM didDismiss: ${ e . message . messageId } ` ) ;
85+ } ,
86+ ) ;
87+ OneSignal . InAppMessages . addEventListener (
88+ 'click' ,
89+ ( e : InAppMessageClickEvent ) => {
90+ log . i ( TAG , `IAM click: ${ e . result . actionId ?? 'unknown' } ` ) ;
91+ } ,
92+ ) ;
93+ OneSignal . Notifications . addEventListener (
94+ 'click' ,
95+ ( e : NotificationClickEvent ) => {
96+ log . i ( TAG , `Notification click: ${ e . notification . title ?? '' } ` ) ;
97+ } ,
98+ ) ;
99+ OneSignal . Notifications . addEventListener (
100+ 'permissionChange' ,
101+ ( granted : boolean ) => {
102+ log . i ( TAG , `Permission changed: ${ granted } ` ) ;
103+ } ,
104+ ) ;
105+ OneSignal . Notifications . addEventListener (
106+ 'foregroundWillDisplay' ,
107+ ( e : NotificationWillDisplayEvent ) => {
108+ log . i (
109+ TAG ,
110+ `Notification foregroundWillDisplay: ${
111+ e . getNotification ( ) . title ?? ''
112+ } `,
113+ ) ;
114+ e . preventDefault ( ) ;
115+ e . getNotification ( ) . display ( ) ;
116+ } ,
117+ ) ;
84118
85119 log . i ( TAG , `OneSignal initialized with app ID: ${ appId } ` ) ;
86120 } catch ( err ) {
@@ -96,7 +130,10 @@ function App() {
96130
97131 return (
98132 < SafeAreaProvider >
99- < StatusBar backgroundColor = { Colors . oneSignalRed } barStyle = "light-content" />
133+ < StatusBar
134+ backgroundColor = { Colors . oneSignalRed }
135+ barStyle = "light-content"
136+ />
100137 < AppContextProvider >
101138 < NavigationContainer >
102139 < Stack . Navigator
@@ -112,7 +149,12 @@ function App() {
112149 options = { {
113150 headerTitle : ( ) => (
114151 < View style = { headerStyles . container } >
115- < Svg width = { 26 } height = { 26 } viewBox = "0 0 70 70" style = { headerStyles . logo } >
152+ < Svg
153+ width = { 26 }
154+ height = { 26 }
155+ viewBox = "0 0 70 70"
156+ style = { headerStyles . logo }
157+ >
116158 < Path
117159 d = "M34.8106 0.345025C15.5675 0.383111 -0.107685 16.1805 0.000557241 35.4237C0.0499825 44.0258 3.27658 52.3062 9.06036 58.6738C14.8441 65.0414 22.7771 69.0471 31.3348 69.921C31.3907 69.9266 31.4472 69.9204 31.5006 69.9028C31.5539 69.8852 31.603 69.8565 31.6446 69.8187C31.6861 69.7809 31.7193 69.7348 31.7419 69.6834C31.7645 69.6319 31.7761 69.5763 31.7758 69.5201V35.2232H29.0657C28.9594 35.2232 28.8574 35.181 28.7822 35.1058C28.707 35.0306 28.6648 34.9286 28.6648 34.8223V29.4102C28.6648 29.3039 28.707 29.2019 28.7822 29.1267C28.8574 29.0515 28.9594 29.0093 29.0657 29.0093H37.5728C37.6791 29.0093 37.7811 29.0515 37.8563 29.1267C37.9314 29.2019 37.9737 29.3039 37.9737 29.4102V69.5201C37.9734 69.5763 37.9849 69.6319 38.0075 69.6834C38.0301 69.7348 38.0633 69.7809 38.1049 69.8187C38.1465 69.8565 38.1955 69.8852 38.2489 69.9028C38.3023 69.9204 38.3588 69.9266 38.4147 69.921C47.317 69.0121 55.5294 64.7164 61.3533 57.9223C67.1771 51.1281 70.1668 42.3555 69.7038 33.4189C69.2409 24.4823 65.3608 16.0654 58.8662 9.90943C52.3715 3.75341 43.7592 0.32918 34.8106 0.345025ZM44.7228 62.1516C44.6622 62.1731 44.5974 62.1798 44.5337 62.171C44.47 62.1622 44.4094 62.1382 44.3569 62.1011C44.3044 62.0639 44.2616 62.0147 44.2322 61.9575C44.2027 61.9004 44.1874 61.837 44.1876 61.7727V56.0479C44.1877 55.934 44.2202 55.8225 44.2812 55.7263C44.3423 55.6301 44.4294 55.5533 44.5324 55.5047C49.1635 53.3017 52.9013 49.5803 55.1247 44.959C57.3481 40.3377 57.9233 35.0947 56.7545 30.1013C55.5858 25.1079 52.7436 20.6648 48.7002 17.5102C44.6568 14.3557 39.6557 12.6797 34.528 12.7609C22.5972 12.9433 12.8073 22.5648 12.4284 34.4916C12.2897 38.8588 13.4263 43.1719 15.6992 46.9037C17.9722 50.6354 21.283 53.6242 25.2271 55.5047C25.3301 55.5533 25.4172 55.6301 25.4782 55.7263C25.5393 55.8225 25.5718 55.934 25.5719 56.0479V61.7727C25.5721 61.837 25.5568 61.9004 25.5273 61.9575C25.4979 62.0147 25.4551 62.0639 25.4026 62.1011C25.3501 62.1382 25.2895 62.1622 25.2258 62.171C25.1621 62.1798 25.0973 62.1731 25.0367 62.1516C19.4788 60.1122 14.6871 56.4048 11.3177 51.5369C7.94824 46.669 6.16583 40.8787 6.21449 34.9586C6.35079 19.3877 19.0753 6.67321 34.6522 6.55895C50.5659 6.43067 63.543 19.3396 63.543 35.2232C63.543 47.5749 55.6974 58.1265 44.7228 62.1516Z"
118160 fill = "white"
0 commit comments