Skip to content

Commit d7d3091

Browse files
authored
Merge pull request #224 from opmat/update-sample-code
Update sample code
2 parents d1e9927 + 5a81776 commit d7d3091

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

examples/RNOneSignalExpoExample/App.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
import React from 'react';
12
import { StatusBar } from 'expo-status-bar';
23
import { StyleSheet, Text, View } from 'react-native';
3-
import OneSignal from 'react-native-onesignal';
4+
import { LogLevel, OneSignal } from "react-native-onesignal";
45

56
const initOneSignal = () => {
6-
OneSignal.setAppId("8fbf6c72-4b80-47a8-86ae-68de02259355");
7-
OneSignal.setLogLevel(6, 0);
8-
OneSignal.promptForPushNotificationsWithUserResponse(response => {
9-
console.log(response);
10-
});
7+
OneSignal.initialize("8fbf6c72-4b80-47a8-86ae-68de02259355");
8+
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
9+
10+
// Also need to enable notifications to complete OneSignal setup
11+
if (await OneSignal.Notifications.canRequestPermission()) {
12+
let permission = OneSignal.Notifications.hasPermission();
13+
if (!permission) {
14+
await OneSignal.Notifications.requestPermission(true);
15+
}
16+
}
17+
OneSignal.setConsentRequired(true);
18+
OneSignal.setConsentGiven(true);
1119
}
1220

1321
export default function App() {

examples/RNOneSignalExpoExample/app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "my-app",
44
"slug": "my-app",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",

examples/RNOneSignalExpoExample/eas.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"cli": {
3-
"version": ">= 0.48.2"
3+
"version": ">= 5.6.0"
44
},
55
"build": {
66
"development": {

examples/RNOneSignalExpoExample/package.json

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "my-app",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"scripts": {
55
"start": "expo start --dev-client",
66
"android": "expo run:android",
@@ -9,22 +9,21 @@
99
"eject": "expo eject"
1010
},
1111
"dependencies": {
12-
"expo": "~45.0.0",
13-
"expo-constants": "^13.1.1",
14-
"expo-dev-client": "~0.9.5",
15-
"expo-splash-screen": "~0.15.1",
16-
"expo-status-bar": "~1.3.0",
17-
"onesignal-expo-plugin": "^1.3.2",
18-
"react": "17.0.2",
19-
"react-dom": "17.0.2",
20-
"react-native": "0.68.2",
21-
"react-native-onesignal": "^4.4.1",
22-
"react-native-web": "0.17.7"
12+
"expo": "~49.0.15",
13+
"expo-constants": "^14.4.2",
14+
"expo-dev-client": "~2.4.12",
15+
"expo-splash-screen": "~0.26.1",
16+
"expo-status-bar": "~1.11.1",
17+
"onesignal-expo-plugin": "^2.0.2",
18+
"react": "18.2.0",
19+
"react-dom": "18.2.0",
20+
"react-native": "0.72.6",
21+
"react-native-onesignal": "^5.0.4",
22+
"react-native-web": "0.19.6"
2323
},
2424
"devDependencies": {
25-
"@babel/core": "^7.12.9",
26-
"@types/react": "~17.0.21",
27-
"@types/react-native": "~0.66.13",
25+
"@babel/core": "^7.20.0",
26+
"@types/react": "~18.2.21",
2827
"typescript": "~4.3.5"
2928
},
3029
"private": true
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "expo/tsconfig.base",
33
"compilerOptions": {
4+
"jsx": "react",
45
"strict": true
56
}
67
}

0 commit comments

Comments
 (0)