Skip to content

Commit 266e91c

Browse files
Merge branch 'hotfix/1.5.1'
2 parents c8cf4ed + ee6aabd commit 266e91c

21 files changed

Lines changed: 120 additions & 38 deletions

SampleApp/App.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,37 @@ import {
44
enableDevMode,
55
initWENotificationInbox,
66
} from 'react-native-webengage-inbox';
7-
import {initWebEngage} from './src/WebEngageHandler/WebEngageManager';
7+
import {
8+
disableWebEngagePush,
9+
enableWebEngagePush,
10+
initWebEngage,
11+
} from './src/WebEngageHandler/WebEngageManager';
12+
import {PermissionsAndroid, Platform} from 'react-native';
813

914
function App(): React.JSX.Element {
1015
enableDevMode();
1116
initWebEngage();
1217
initWENotificationInbox();
18+
// Rquesting permission for Android
19+
const requestAndroidPermissions = async () => {
20+
try {
21+
const granted = await PermissionsAndroid.request(
22+
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
23+
);
24+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
25+
enableWebEngagePush();
26+
console.log('Android permissions granted');
27+
} else {
28+
disableWebEngagePush();
29+
console.log('Android permissions denied');
30+
}
31+
} catch (err) {
32+
console.warn(err);
33+
}
34+
};
35+
if (Platform.OS === 'android' && Platform.Version >= 31) {
36+
requestAndroidPermissions();
37+
}
1338

1439
return <AppNavigator />;
1540
}

SampleApp/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {AppRegistry} from 'react-native';
22
import App from './App';
3-
// TODO change source to exact App
43
import {name as appName} from './app.json';
54

65
AppRegistry.registerComponent(appName, () => App);

SampleApp/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
},
1212
"dependencies": {
1313
"@react-native-async-storage/async-storage": "^1.21.0",
14-
"react-native-webengage": "^1.5.0",
15-
"react-native-webengage-inbox": "1.0.0",
1614
"@react-native-picker/picker": "^2.6.1",
17-
"@react-navigation/native": "^6.1.9",
15+
"@react-navigation/native": "^6.1.17",
1816
"@react-navigation/native-stack": "^6.9.17",
1917
"@react-navigation/stack": "^6.3.20",
2018
"react": "18.2.0",
@@ -23,8 +21,11 @@
2321
"react-native-gesture-handler": "^2.14.1",
2422
"react-native-loading-spinner-overlay": "^3.0.1",
2523
"react-native-modal": "^13.0.1",
26-
"react-native-safe-area-context": "^4.8.2",
27-
"react-native-we-personalization": "^1.0.0"
24+
"react-native-safe-area-context": "^4.9.0",
25+
"react-native-screens": "^3.30.1",
26+
"react-native-we-personalization": "^1.0.0",
27+
"react-native-webengage": "^1.5.0",
28+
"react-native-webengage-inbox": "1.0.0"
2829
},
2930
"devDependencies": {
3031
"@babel/core": "^7.20.0",

SampleApp/src/Navigation/AppNavigator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import HomeScreen from '../screens/HomeScreen';
99
import InlineScreen from '../screens/InlineScreen';
1010
import {StyleSheet} from 'react-native';
1111
import COLORS from '../Styles/Colors';
12-
import CONSTANTS from '../Utils/Constants';
12+
import CONSTANTS from '../utils/Constants';
1313
import ScreenComponent from '../screens/ScreenComponent';
1414
import ScreenList from '../screens/Inline/ScreenList';
1515
import ScreenDetails from '../screens/Inline/ScreenDetails';

SampleApp/src/WebEngageHandler/WebEngageManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Alert} from 'react-native';
22
import WebEngage from 'react-native-webengage';
3-
import CONSTANTS from '../Utils/Constants';
3+
import CONSTANTS from '../utils/Constants';
44

55
const webEngageManager = new WebEngage();
66

@@ -11,6 +11,7 @@ export const initWebEngage = () => {
1111
webEngageManager.notification.onPrepare(function (notificationData) {
1212
console.log(
1313
CONSTANTS.WEBENGAGE_INAPP + 'App: in-app notification prepared',
14+
+JSON.stringify(notificationData),
1415
);
1516
});
1617

@@ -45,10 +46,18 @@ export const initWebEngage = () => {
4546

4647
webEngageManager.push.onClick(function (notificationData) {
4748
console.log(
48-
CONSTANTS.WEBENGAGE_INAPP +
49+
CONSTANTS.WEBENGAGE_PUSH +
4950
' push-notification clicked with payload: ' +
5051
JSON.stringify(notificationData.userData),
5152
);
5253
Alert.alert('It is a Simple Alert ' + JSON.stringify(notificationData));
5354
});
5455
};
56+
57+
export const enableWebEngagePush = () => {
58+
webEngageManager.user.setDevicePushOptIn(true);
59+
};
60+
61+
export const disableWebEngagePush = () => {
62+
webEngageManager.user.setDevicePushOptIn(false);
63+
};

SampleApp/src/screens/EventComponent/EventsScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import WEUserModal from '../../CommonComponents/WEUserModal';
88
import WEButton from '../../CommonComponents/WEButton';
99
import ShoppingEventsScreen from './ShoppingEventScreen';
1010
import webEngageManager from '../../WebEngageHandler/WebEngageManager';
11-
import CONSTANTS from '../../Utils/Constants';
11+
import CONSTANTS from '../../utils/Constants';
1212

1313
const EventsScreen = () => {
1414
const [eventName, setEventName] = useState<string>('');

SampleApp/src/screens/EventComponent/ShoppingEventScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {View, ScrollView, Text, StyleSheet} from 'react-native';
33
import BouncyCheckbox from 'react-native-bouncy-checkbox';
44
import WEButton from '../../CommonComponents/WEButton';
55
import webEngageManager from '../../WebEngageHandler/WebEngageManager';
6-
import CONSTANTS from '../../Utils/Constants';
6+
import CONSTANTS from '../../utils/Constants';
77

88
const ShoppingEventsScreen: React.FC = () => {
99
const [tvCheckbox, setTvCheckbox] = useState(true);

SampleApp/src/screens/HomeScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import {
99
} from 'react-native';
1010
import {navigate} from '../Navigation/NavigationService';
1111
import WEButton from '../CommonComponents/WEButton';
12-
import WEModal from '../Utils/WEModal';
12+
import WEModal from '../utils/WEModal';
1313
import COLORS from '../Styles/Colors';
1414
import webEngageManager from '../WebEngageHandler/WebEngageManager';
15-
import AsyncStorageUtil from '../Utils/AsyncStorageUtils';
15+
import AsyncStorageUtil from '../utils/AsyncStorageUtils';
1616
import {useIsFocused} from '@react-navigation/native';
1717
import {
1818
getNotificationCount,
1919
resetNotificationCount,
2020
} from 'react-native-webengage-inbox';
21-
import CONSTANTS from '../Utils/Constants';
21+
import CONSTANTS from '../utils/Constants';
2222

2323
// TODO Add Navigation Type
2424
const HomeScreen = ({navigation}) => {

SampleApp/src/screens/Inline/DynamicScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import webEngageManager from '../../WebEngageHandler/WebEngageManager';
2323
import NavigationModal from '../../Navigation/NavigationModal';
2424
import WETextInput from '../../CommonComponents/WETextInput';
2525
import WEButton from '../../CommonComponents/WEButton';
26-
import AsyncStorageUtil from '../../Utils/AsyncStorageUtils';
27-
import CONSTANTS from '../../Utils/Constants';
26+
import AsyncStorageUtil from '../../utils/AsyncStorageUtils';
27+
import CONSTANTS from '../../utils/Constants';
2828
import COLORS from '../../Styles/Colors';
2929

3030
interface DynamicScreenProps {

SampleApp/src/screens/Inline/ScreenDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import BouncyCheckbox from 'react-native-bouncy-checkbox';
55
import InlineViewModal from '../../CommonComponents/InlineViewModal';
66
import WEButton from '../../CommonComponents/WEButton';
77
import WETextInput from '../../CommonComponents/WETextInput';
8-
import AsyncStorageUtil from '../../Utils/AsyncStorageUtils';
8+
import AsyncStorageUtil from '../../utils/AsyncStorageUtils';
99
import COLORS from '../../Styles/Colors';
1010

1111
interface ScreenDetailsProps {

0 commit comments

Comments
 (0)