Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Package.json
- {
- "name": "elvismobile",
- "version": "0.0.1",
- "private": true,
- "scripts": {
- "android": "react-native run-android",
- "ios": "react-native run-ios",
- "start": "react-native start",
- "test": "jest",
- "lint": "eslint ."
- },
- "dependencies": {
- "@react-native-async-storage/async-storage": "^1.17.4",
- "@react-native-community/datetimepicker": "^6.1.3",
- "@react-native-community/push-notification-ios": "^1.10.1",
- "@react-native-firebase/app": "^14.9.4",
- "@react-native-firebase/messaging": "^14.9.4",
- "@react-native-picker/picker": "^2.4.1",
- "@react-navigation/bottom-tabs": "^6.3.1",
- "@react-navigation/native": "^6.0.10",
- "@react-navigation/native-stack": "^6.6.2",
- "axios": "^0.27.2",
- "formik": "^2.2.9",
- "moment": "^2.29.3",
- "react": "17.0.2",
- "react-native": "0.68.2",
- "react-native-actions-sheet": "^0.6.0",
- "react-native-animatable": "^1.3.3",
- "react-native-banner-carousel": "^1.0.3",
- "react-native-blob-util": "^0.14.0",
- "react-native-calendars": "^1.1274.0",
- "react-native-collapsible": "^1.6.0",
- "react-native-currency-input": "^1.0.1",
- "react-native-customisable-alert": "^0.1.20",
- "react-native-document-picker": "^7.1.3",
- "react-native-easy-grid": "^0.2.2",
- "react-native-element-dropdown": "^1.5.9",
- "react-native-flash-message": "^0.2.0",
- "react-native-geolocation-service": "^5.3.0-beta.4",
- "react-native-gesture-handler": "^2.1.0",
- "react-native-image-zoom-viewer-fixed": "^3.2.5",
- "react-native-keyboard-aware-scroll-view": "^0.9.5",
- "react-native-modal": "^13.0.1",
- "react-native-modal-datetime-picker": "^13.0.1",
- "react-native-month-year-picker": "^1.8.0",
- "react-native-pdf": "^6.4.0",
- "react-native-push-notification": "^8.1.1",
- "react-native-ratings-fix": "^6.5.8",
- "react-native-responsive-fontsize": "^0.5.1",
- "react-native-responsive-screen": "^1.4.2",
- "react-native-safe-area-context": "^3.3.2",
- "react-native-screens": "^3.12.0",
- "react-native-select-two": "^1.1.0",
- "react-native-signature-canvas": "^4.3.0",
- "react-native-svg": "^12.1.1",
- "react-native-svg-transformer": "^0.14.3",
- "react-native-text-input-mask": "^3.1.4",
- "react-native-unlock-slider": "^1.0.6",
- "react-native-vector-icons": "^9.0.0",
- "react-native-webview": "^11.16.0",
- "react-redux": "^7.2.6",
- "redux": "^4.1.2",
- "redux-persist": "^6.0.0",
- "redux-thunk": "^2.4.1",
- "rn-fetch-blob": "^0.12.0",
- "rn-select-date-range": "^3.2.2",
- "yup": "^0.32.11"
- },
- "devDependencies": {
- "@babel/core": "^7.12.9",
- "@babel/runtime": "^7.12.5",
- "@react-native-community/eslint-config": "^2.0.0",
- "babel-jest": "^26.6.3",
- "eslint": "^7.32.0",
- "jest": "^26.6.3",
- "metro-react-native-babel-preset": "^0.67.0",
- "react-test-renderer": "17.0.2"
- },
- "jest": {
- "preset": "react-native"
- }
- }
- // App.js
- // In App.js in a new project
- import React, {useEffect} from 'react';
- import {Provider} from 'react-redux';
- import {store, persistor} from './redux/helpers/store';
- import {PersistGate} from 'redux-persist/integration/react';
- import {NavigationContainer} from '@react-navigation/native';
- import {Platform, StatusBar, Text, View} from 'react-native';
- import FlashMessage from 'react-native-flash-message';
- import Router from './router';
- import PushNotification from 'react-native-push-notification';
- import {notifAlert} from './utils';
- import AsyncStorage from '@react-native-async-storage/async-storage';
- function App() {
- const storeData = async token => {
- try {
- await AsyncStorage.setItem('device_token', token);
- } catch (error) {}
- };
- useEffect(() => {
- StatusBar.setBarStyle('light-content');
- if (Platform.OS === 'android') {
- StatusBar.setBackgroundColor('rgba(0,0,0,0.1)');
- StatusBar.setTranslucent(true);
- }
- PushNotification.configure({
- // (optional) Called when Token is generated (iOS and Android)
- onRegister: function (token) {
- storeData(token.token);
- },
- // (required) Called when a remote is received or opened, or local notification is opened
- onNotification: function (notification) {
- console.log('NOTIFICATION:', notification);
- if (notification.hasOwnProperty('channelId')) {
- notifAlert(notification.data.title, notification.data.body);
- }
- },
- // (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android)
- onAction: function (notification) {
- console.log('ACTION:', notification.action);
- console.log('NOTIFICATION:', notification);
- // process the action
- },
- // (optional) Called when the user fails to register for remote notifications. Typically occurs when APNS is having issues, or the device is a simulator. (iOS)
- onRegistrationError: function (err) {
- console.error(err.message, err);
- },
- // IOS ONLY (optional): default: all - Permissions to register.
- permissions: {
- alert: true,
- badge: true,
- sound: true,
- },
- senderID: '916470534384',
- popInitialNotification: true,
- requestPermissions: true,
- });
- PushNotification.createChannel(
- {
- channelId: 'approval-notification', // (required)
- channelName: 'Approval Notification', // (required)
- channelDescription: 'A Notification for Approval', // (optional) default: undefined.
- },
- () => {}, // (optional) callback returns whether the channel was created, false means it already existed.
- );
- }, []);
- return (
- <NavigationContainer>
- <StatusBar />
- <Provider store={store}>
- <PersistGate loading={null} persistor={persistor}>
- <Router />
- </PersistGate>
- </Provider>
- <FlashMessage position="top" />
- </NavigationContainer>
- );
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement