Skip to content

Commit

Permalink
Merge pull request #224 from opmat/update-sample-code
Browse files Browse the repository at this point in the history
Update sample code
  • Loading branch information
rgomezp authored Mar 25, 2024
2 parents d1e9927 + 5a81776 commit d7d3091
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
20 changes: 14 additions & 6 deletions examples/RNOneSignalExpoExample/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import React from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import OneSignal from 'react-native-onesignal';
import { LogLevel, OneSignal } from "react-native-onesignal";

const initOneSignal = () => {
OneSignal.setAppId("8fbf6c72-4b80-47a8-86ae-68de02259355");
OneSignal.setLogLevel(6, 0);
OneSignal.promptForPushNotificationsWithUserResponse(response => {
console.log(response);
});
OneSignal.initialize("8fbf6c72-4b80-47a8-86ae-68de02259355");
OneSignal.Debug.setLogLevel(LogLevel.Verbose);

// Also need to enable notifications to complete OneSignal setup
if (await OneSignal.Notifications.canRequestPermission()) {
let permission = OneSignal.Notifications.hasPermission();
if (!permission) {
await OneSignal.Notifications.requestPermission(true);
}
}
OneSignal.setConsentRequired(true);
OneSignal.setConsentGiven(true);
}

export default function App() {
Expand Down
2 changes: 1 addition & 1 deletion examples/RNOneSignalExpoExample/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "my-app",
"slug": "my-app",
"version": "1.0.0",
"version": "1.0.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
Expand Down
2 changes: 1 addition & 1 deletion examples/RNOneSignalExpoExample/eas.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cli": {
"version": ">= 0.48.2"
"version": ">= 5.6.0"
},
"build": {
"development": {
Expand Down
29 changes: 14 additions & 15 deletions examples/RNOneSignalExpoExample/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "my-app",
"version": "1.0.0",
"version": "1.0.1",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
Expand All @@ -9,22 +9,21 @@
"eject": "expo eject"
},
"dependencies": {
"expo": "~45.0.0",
"expo-constants": "^13.1.1",
"expo-dev-client": "~0.9.5",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"onesignal-expo-plugin": "^1.3.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-onesignal": "^4.4.1",
"react-native-web": "0.17.7"
"expo": "~49.0.15",
"expo-constants": "^14.4.2",
"expo-dev-client": "~2.4.12",
"expo-splash-screen": "~0.26.1",
"expo-status-bar": "~1.11.1",
"onesignal-expo-plugin": "^2.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
"react-native-onesignal": "^5.0.4",
"react-native-web": "0.19.6"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/react": "~17.0.21",
"@types/react-native": "~0.66.13",
"@babel/core": "^7.20.0",
"@types/react": "~18.2.21",
"typescript": "~4.3.5"
},
"private": true
Expand Down
1 change: 1 addition & 0 deletions examples/RNOneSignalExpoExample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"jsx": "react",
"strict": true
}
}

0 comments on commit d7d3091

Please sign in to comment.