Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28469 articles
Browse latest View live

React Native Maps: Markers image doesn't show using Custom Marker in react-native-maps

$
0
0

I'm using react-native-maps but I faced a problem that after a lot of googling without answer makes me ask it here.I'm trying to use Custom Marker for the marker in the map as the following picture

enter image description here

  • as I searched I found out that needed to use Custom Marker to accomplish the maker's design, then I created a Custom Marker component

    import React, { Component } from "react";import { View } from "react-native";import {Text,Left,Right,Thumbnail,} from "native-base";const defaultEmployeeLogo = require("../../../assets/defualtEmployee.png");class CustomMarker extends Component {render() {    return (<View style={{ flexDirection: 'row', width: 140, height: 60,       borderRadius: 70, backgroundColor: 'orange' }}><Left><Thumbnail source={defaultEmployeeLogo} /></Left><Right><Text style={{                color: '#fef',                fontSize: 13,                paddingBottom: 2,                fontFamily: 'Roboto',                alignItems: 'center',                paddingRight: 10            }}>Mohammad</Text></Right></View >);   }}export default CustomMarker;

when I use CustomMarker.js class solely it works fine and it shows the image but when I use it as the marker custom view it doesn't show the image

enter image description here

I don't know why it can't render the image with Custom Marker in android.and here is my code where I'm using map, markers and custom marker class

return (<View style={styles.map_container}><MapView      style={styles.map}      customMapStyle={customrMapStyle}      region={{        latitude: this.state.region.latitude,        longitude: this.state.region.longitude,        latitudeDelta: 0.4,        longitudeDelta: 0.41,      }} >      {        coordinationData.map(function (marker, i) {          let lat = marker.latLang.latitude;          let lang = marker.latLang.longitude;<MapView.Marker            key={i}            coordinate={              {                latitude: lat,                longitude: lang,                latitudeDelta: 0.4,                longitudeDelta: 0.41              }            }            title={marker.title}            description={marker.description}><CustomMarker /></MapView.Marker>        })}</MapView></View>

any kind of help would be appreciated.


How to get current country of Device in React Native (iOS and Android)?

$
0
0

I am trying to get current country of device in but didn't find anything. Is there something to do so in React Native?I tried using react-native-device-info but it is also not supporting but in previous version it can be get by getDeviceCountry(). Now for the latest version it is showing error:

TypeError: _reactNativeDeviceInfo.default.getDeviceCountry is not a function. (In '_reactNativeDeviceInfo.default.getDeviceCountry()','_reactNativeDeviceInfo.default.getDeviceCountry' is undefined)

Axios POST request gives a "Network Error" when adding image to FormData structure in React Native

$
0
0

I'm currently building a simple app in React Native 0.62.2 for Android. I've been having some trouble with axios 0.19.2 (or even the fetch API) when trying to upload images to my API (which is written in node.js/express). The POST request is formulated as follows:

// UserService.jsexport const postNewUser = async (newUser) => {    try {        const photo = {            uri: newUser.avatar.uri,            type: 'image/jpg',            name: newUser.avatar.fileName,        };        const formData = new FormData();        Object.keys(newUser).forEach(key => formData.append(key, newUser[key]));        formData.append('avatar', photo);        const response = await api.post('/users', formData);        return response.data;    } catch (err) {        console.log('TRACE error posting user: ', err);        return;    }}

Here, the property newUser.avatar.uri is set by means of an image picker library, namely @react-native-image-picker 1.6.1. It gives me a NetworkError whenever I append the photo variable into the FormData. Setting the URI manually with some random image from the web results in the same error. Debbuging it from the Browser, it prints out some sort of stack trace like this one:

TRACE error posting user:  Error: Network Error    at createError (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\axios\lib\core\createError.js:16)    at EventTarget.handleError (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\axios\lib\adapters\xhr.js:83)    at EventTarget.dispatchEvent (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\event-target-shim\dist\event-target-shim.js:818)    at EventTarget.setReadyState (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:575)    at EventTarget.__didCompleteResponse (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:389)    at C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:502    at RCTDeviceEventEmitter.emit (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189)    at MessageQueue.__callFunction (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:425)    at C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112    at MessageQueue.__guard (C:\Users\Dell\Documents\Projetos\SmartestVet\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:373)

If I, for example, comment out the line formData.append('avatar', photo); it works perfectly, i.e., my API receives the request accordingly. So I think this might not be a CORS-related issue. Also, other requests, such as GETs and even other POSTs are working just fine.

I know there's a bunch of other related posts here in SO and also in GitHub, some of them related to the exact same issue. But none of the solutions I found worked out for me.

In case someone wants to check out how the routes in my API are implemented just hit me up and I will provide the code here.

Thanks in advance for any help you might give me!

What is {...props} and how to get my function from other

$
0
0

I'm trying to learn react native and especially react navigation v5.

According to this topic: https://reactnavigation.org/docs/themes/#using-the-current-theme-in-your-own-components, I try to make a dark mode but I don't understand how to call my toggleTheme() function in the TouchableRipple.

My App.js :

const [isDarkTheme, setIsDarkTheme] = React.useState(false);const theme = isDarkTheme ? CombinedDarkTheme : CombinedDefaultTheme;function toggleTheme() {    setIsDarkTheme(isDark => !isDark);}return (<PaperProvider theme={theme}><NavigationContainer theme={theme}><Drawer.Navigator drawerContent={props => <DrawerContent {...props} />}>                    //{...other things...}</Drawer.Navigator></NavigationContainer></PaperProvider>);

My DrawerContent.js :

export function DrawerContent(props) {    const paperTheme = useTheme();    //{...other things...}<DrawerContentScrollView {...props}>        //{...other things...}<Drawer.Section title="Préférences"><TouchableRipple onPress={props.toggleTheme}><View style={styles.preferences}><Text>Dark Theme</Text><View pointerEvents="none"><Switch value={paperTheme.dark} /></View></View></TouchableRipple>    //{...other things...}

Accoding to the topic, If I call onPress={props.toggleTheme} the darktheme will appear, but this is not working, So how to call this function from App.js in DrawerContent.js

The toggle is moving if I set <Switch value={!paperTheme.dark} so useTheme(); seems to be working.

And last question, what is {...props}, I can't log it because he return out of memory.

Thanks for people who can help me to understand this!

Cross platform Mobile SDK with react native for IOS and Android

$
0
0

I am beginner to react native. Please forgive if it is a very basic question. I have a Javascript client library which I want to write for both IOS and Android also. Instead of writing separately. would like to know if I could create such libraries using React Native.Like writing the library in react native and convert it to IOS or Android compatible. like adding the dependency in the existing Native application like Android or Swift codebase.

I checked with many articles where everything is explaining about integrating the react native app to native application with View but what I am looking for is different I need to integrate that library like dependency.Kindly help me with this.

Thanks in Advance.

React Native: The development server returned response error code 404

$
0
0

I am trying to run a react native app on my computer, using an a Ngrok server. I am using port 8081 on my computer, when i run the command npm start in terminal my server runs on the port, and when i cancel the process in terminal the page cant be reached. So everything seems to be in order there (its not another service running on that port).

When im trying to connect from my phone, using the Viro Media app, i get this error:

Image of the error form my phone

I have been going through too many google-pages on solutions, but i cant understand whats wrong. I also have been allowing connections to my computer in my security options, turned off the firewall, dubble checked that im in the correct folder etc.

Thanks in advance.

How to configure Local Notifications in expo?

$
0
0

I am fairly new to react-native and still learning. I am trying to configure local notifications for an android device, but it's not working. While trying to solve this issue, I learned that Permissions has moved out of expo, and Notifications for android require a separate object to be created for sound and vibration to work. The examples on the other websites also do not seem to work. (maybe there is an update). I have already tried importing "Permissions" from the new "expo-permissions" but still, it is not working! Please help!!

Here is my code:

import React, { Component } from 'react';import { Text, View, ScrollView, StyleSheet, Picker, Switch, Button, Alert } from 'react-native';import { Card } from 'react-native-elements';import DatePicker from 'react-native-datepicker';import * as Animatable from 'react-native-animatable'; import Notifications from 'expo';import * as Permissions from 'expo-permissions';class Reservation extends Component {    constructor(props) {        super(props);        this.state = {            guests: 1,            smoking: false,            date: '',            showModal: false        }    }    toggleModal() {        this.setState({showModal: !this.state.showModal});    }    resetForm() {        this.setState({            guests: 1,            smoking: false,            date: ''        })    }    async obtainNotificationPermission() {        let permission = await Permissions.getAsync(Permissions.USER_FACING_NOTIFICATIONS)        if (permission.status !== 'granted') {            permission =await Permissions.askAsync(Permissions.USER_FACING_NOTIFICATION);            console.log("Permission Status: "+permission);            if (permission.status !== 'granted') {                Alert.alert('Permission not granted to show notifications!')            }        }        return permission;    }    async presentLocalNotification(date) {        await this.obtainNotificationPermission();        console.log("Permission Status: "+this.obtainNotificationPermission());        Notifications.presentLocalNotificationAsync({            title: 'Your Reservation',            body: 'Reservation for '+ date +' requested',            ios: {                sound: true            },            android: {                sound: true,                vibrate: true,                color: '#512DA8'            }        });    }    handleReservation() {        console.log(JSON.stringify(this.state));        this.toggleModal();        this.presentLocalNotification(this.state.date);    }    render() {        return(<ScrollView><Animatable.View animation="zoomIn" duration={400} delay={100}><View style={styles.formRow}><Text style={styles.formLabel}>Number of Guests</Text><Picker                            style={styles.formItem}                            selectedValue={this.state.guests}                            onValueChange={(itemValue, itemIndex) => this.setState({ guests: itemValue })} ><Picker.Item label = '1' value = '1' /><Picker.Item label = '2' value = '2' /><Picker.Item label = '3' value = '3' /><Picker.Item label = '4' value = '4' /><Picker.Item label = '5' value = '5' /><Picker.Item label = '6' value = '6' /></Picker></View><View style={styles.formRow}><Text style={styles.formLabel}>Smoking</Text><Switch                            style={styles.formItem}                            value={this.state.smoking}                            onTintColor='#512da8'                            onValueChange={(value) => this.setState({smoking: value })} ></Switch></View><View style={styles.formRow}><Text style={styles.formLabel}>Date and Time</Text><DatePicker                            style={{flex: 2, marginRight: 20}}                            date = {this.state.date}                            format=''                            mode='datetime'                            placeholder='Select date and time '                            minDate= '2017-01-01'                            confirmBtnText='Confirm'                            cancelBtnText='Cancel'                            customStyles={{                                dateIcon: {                                    position: 'absolute',                                    left: 0,                                    top: 4,                                    marginLeft: 0                                },                                dateInput: {                                    marginLeft: 36                                }                            }}                            onDateChange = {(date) => {this.setState({ date: date})}}                            /></View><View style={styles.formRow}><Button                            title='Reserve'                            color='#512da8'                            accessibilityLabel='Learn more about this purple button'                            onPress={() => {                                Alert.alert('Confirm Reservation!','Number of guests: '+this.state.guests+'\n'+'Smoking: '+this.state.smoking+'\n'+'Date and Time: '+this.state.date,                                [                                    { text: 'Cancel', onPress: () => {this.resetForm(); console.log('Reservation not confirmed')},                                        style: 'cancel' },                                    { text: 'Ok', onPress: () => {this.handleReservation(); this.resetForm()} }                                ],                                { cancelable: false }                            ); }}                            /></View></Animatable.View></ScrollView>        );    }}const styles = StyleSheet.create({    formRow: {        alignItems: 'center',        justifyContent: 'center',        flex: 1,        flexDirection: 'row',        margin: 20    },    formLabel: {        fontSize: 18,        flex: 2    },    formItem: {        flex: 1    },    modal: {        justifyContent: 'center',        margin: 20    },    modalTitle: {        fontSize: 24,        fontWeight: 'bold',        backgroundColor: '#512da8',        textAlign: 'center',        color:'white',        marginBottom: 20    },    modalText: {        fontSize: 18,        margin: 10    }});export default Reservation;

React Native Integration with Android Pay and Apple Pay + Stripe

$
0
0

For several days I’ve been looking for a working library for payments using google pay & android pay and with stripe support


Images not appearing when running from APK

$
0
0

This issue relates to Android.

We have recently migrated our react-native project from Expo to bare workflow. We have an issue however whereby images are not loading when running the built apk file.

When debugging on an emulator or device using react-native android everything works fine. However on a built apk images simply do not appear.

Our build is being conducted as follows

react-native bundle --platform android /     --dev false /     --entry-file index.js      --bundle-output android/app/src/main/assets/app.bundle      --assets-dest android/app/src/main/resandroid/gradlew -p android cleanandroid/gradlew -p android assembleRelease

I can see that the first step bundles our images into the following directory

android/app/src/main/res/drawable-mdpi

The project structure looks like this

index.jsApp.js   ios/   android/   app/      assets/         package.json         images/            image01.png            image02.png      screens/         MyScreen.js

app/assets/package.json to allow us to avoid absolute paths contains

{ "name": "@assets"}

and within MyScreen.js we have, within the render() method

<Image source={require('@assets/images/image01.png')} />

Unpacking the built apk (app-release.apk) I can see that the images are referenced in the MANIFEST.MF file

/release/app-release/META-INF

like so

Name: res/drawable-mdpi-v4/app_assets_images_image01.pngSHA-256-Digest: [BLAH]Name: res/drawable-mdpi-v4/app_assets_images_image02.pngSHA-256-Digest: [BLAH]

within release/app-release/res/drawable-mdpi-v4

the images are present and accounted for having the same name as the manifest.

So I am utterly confused as to why they do not display when running the apk on a device.

This is not an uncommon issue and there are several other Stack Overflow issues along this vein, however I have gone through all of them and none of the suggested solutions work for us.

Gradle version=5.6.3

RN version=61.5

How to get permissions to access the Android Image Gallery in React-Native?

$
0
0

Using the image picker, my app can successfully access the iOS camera roll using this code:

  getPermissionAsync = async () => {    if (Constants.platform.ios) {      const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);      if (status !== 'granted') {        alert('Sorry, you must grant camera roll permissions in order to do this.');      }    }    if (Constants.platform.android) {      const { statusA } = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);      if (statusA !== PermissionsAndroid.RESULTS.GRANTED) {        alert('Sorry, you must grant camera roll permissions in order to do this.');      }    }  };

However, it does not work for Android. Can anyone tell me how to get permission to access the image gallery on android devices?

Thanks

Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

$
0
0

I'm new in React Native. I wanted to run a project with the command:

npx react-native run-android

In summary this error appears:

Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for detailsjava.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7* What went wrong:Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

I read about the problem and I think that the problem is the gradle version. In the build.gradle I have:

buildscript {    ext {        buildToolsVersion = "28.0.3"        minSdkVersion = 16        compileSdkVersion = 28        targetSdkVersion = 28    }    repositories {        google()        jcenter()    }    dependencies {        classpath("com.android.tools.build:gradle:3.5.2")        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}

And my JDK version is 14.0.1. How can I solve this problem?

Change backgroundColor BEHIND keyboard with React Native?

$
0
0

This sounds needless and crazy, but it's actually much more sane than it sounds.

I've been trying to find a way to do this and am pretty close to giving up. Currently I assume it's not possible.

What I'd like to do is change the color behind the keyboard so that the app doesn't have a big white area in the app switcher.

enter image description here

React Native: Opening a WebView modal over a WebView on android freezes the underlying WebView after closing the modal

$
0
0

I've created a react native app where one screen is a WebView form where pressing a button opens up a custom made Modal whose content is another WebView, thereby allowing the user to navigate away from the form and return to it without having to restart filling out the form again.

When you close this Modal everything functions correctly on iOS, but on Android the underlying WebView becomes either a blank screen or frozen when you close the Modal.

I suspect that this may be an issue with the native Android WebView, but I am unfamiliar with the Android ecosystem. Can you have 2 WebViews stacked on top of each other in Android?

Trying to create first react native app getting Build Failed error

$
0
0

Trying to create my first App.

Getting this error refereed tried with some commends unable to install app.

can any one please tell me what is going wrong.

Unable to resolve module `scheduler/tracing` react native

$
0
0

i get some error like this in react-native run-android process

error: bundling failed: Error: Unable to resolve module `scheduler/tracing` from `/Users/miftahali/projects/react/appscustomec/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js`: Module `scheduler/tracing` does not exist in the Haste module map

this my Environment

React Native Environment Info:    System:      OS: macOS 10.14.2      CPU: (4) x64 Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz      Memory: 38.67 MB / 4.00 GB      Shell: 3.2.57 - /bin/bash    Binaries:      Node: 10.0.0 - ~/.nvm/versions/node/v10.0.0/bin/node      npm: 5.6.0 - ~/.nvm/versions/node/v10.0.0/bin/npm      Watchman: 4.9.0 - /usr/local/bin/watchman    SDKs:      iOS SDK:        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1      Android SDK:        API Levels: 19, 20, 23, 25, 26, 27        Build Tools: 23.0.1, 25.0.3, 26.0.1, 27.0.3, 28.0.3    IDEs:      Android Studio: 3.2 AI-181.5540.7.32.5056338      Xcode: 10.1/10B61 - /usr/bin/xcodebuild    npmPackages:      react: 16.4.1 => 16.4.1       react-native: ^0.57.8 => 0.57.8     npmGlobalPackages:      create-react-native-app: 1.0.0

How to resolve this ?, thanks


'installDebug' not found in root project 'android' React Native

$
0
0

I am trying to run my project on the android simulator. When I run react-native run-android I am getting the following:

FAILURE: Build failed with an exception.* What went wrong: Task 'installDebug' not found in root project 'android'.* Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.BUILD FAILED

If I run ./gradlew tasks I get:

Build Setup tasks-----------------init - Initializes a new Gradle build. [incubating]wrapper - Generates Gradle wrapper files. [incubating]Help tasks----------buildEnvironment - Displays all buildscript dependencies declared in root project 'android'.components - Displays the components produced by root project 'android'. [incubating]dependencies - Displays all dependencies declared in root project 'android'.dependencyInsight - Displays the insight into a specific dependency in root project 'android'.help - Displays a help message.model - Displays the configuration model of root project 'android'. [incubating]projects - Displays the sub-projects of root project 'android'.properties - Displays the properties of root project 'android'.tasks - Displays the tasks runnable from root project 'android'.

Any idea why I don't have a installDebug task in my project? How do I get it back?

error: package com.android.annotations does not exist

$
0
0

I have the following class

import com.android.annotations.NonNullByDefault;@NonNullByDefaultpublic final class Log {    ...}

and here is my build.gradle file (some parts omitted)

apply plugin: 'com.android.application'android {    compileSdkVersion 25    buildToolsVersion '24.0.1'    defaultConfig {        minSdkVersion 16        targetSdkVersion 25        versionCode 2        versionName "0.2"    }    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_7        targetCompatibility JavaVersion.VERSION_1_7    }}dependencies {        compile 'com.android.support:appcompat-v7:25.0.0'    compile 'com.android.support:support-annotations:25.0.0'    compile 'com.android.support:design:25.0.0'}

In Android Studio there is no warning raised for my class

enter image description here

However when I try to build and run my app I get this error from gradle

Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]Warning:[options] bootstrap class path not set in conjunction with -source 1.7/home/puter/git-repos/TaskManager3/app/src/main/java/com/treemetrics/taskmanager3/util/Log.javaError:(3, 31) error: package com.android.annotations does not existError:(7, 2) error: cannot find symbol class NonNullByDefaultError:Execution failed for task ':app:compileDebugJavaWithJavac'.> Compilation failed; see the compiler error output for details.Information:BUILD FAILEDInformation:Total time: 21.021 secsInformation:3 errorsInformation:1 warningInformation:See complete output in console

react-native how getPackageName?

$
0
0

I want to get the Android package name:

How to use react-native?

this.getPackageManager().getPackageInfo(this.getPackageName(), 0);    

Getting "java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so" error

$
0
0

I'm in the process of migrating a React Native project from react-native version 0.58.5 to 0.60.4.

For the Android part I've done all the changes mentioned here

I let Hermes disabled in my app build.gradle file:

project.ext.react = [    entryFile: "index.js",    enableHermes: false,  // clean and rebuild if changing]...def jscFlavor = 'org.webkit:android-jsc:+'def enableHermes = project.ext.react.get("enableHermes", false);...dependencies {    ...    if (enableHermes) {      println 'Hermes is enabled'      def hermesPath = "../../node_modules/hermesvm/android/";      debugImplementation files(hermesPath +"hermes-debug.aar")      releaseImplementation files(hermesPath +"hermes-release.aar")    } else {      println 'Hermes is disabled'      implementation jscFlavor    }}...

I can see the Hermes is disabled print at build time. And this is exactly what I want.

When launching the Android app with react-native run-android I get the following crash at startup :

FATAL EXCEPTION: create_react_contextE  Process: com.reactnativetestapp, PID: 21038E  java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.soE      at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)E      at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)E      at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)E      at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)E      at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)E      at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)E      at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)E      at java.lang.Thread.run(Thread.java:764)

After some research I could see this crash occurs for people wanting to enable Hermes and that has a wrong gradle configuration : [0.60.3] App crash on startup when enabling Hermes (enableHermes: true)

Why am I getting this crash while Hermes is disabled?

Note that when setting enableHermes to true no crash occurs.

Configuring Local Notifications in expo for android devices?

$
0
0

I am fairly new to react-native and still learning. I am trying to configure local notifications for an android device, but it's not working. While trying to solve this issue, I learned that Permissions has moved out of expo, and Notifications for android require a separate object to be created for sound and vibration to work. The examples on the other websites also do not seem to work. (maybe there is an update). I have already tried importing "Permissions" from the new "expo-permissions" but still, it is not working! Please help!!

Here is my code:

import Notifications from 'expo';import * as Permissions from 'expo-permissions';
async obtainNotificationPermission() {        let permission = await Permissions.getAsync(Permissions.USER_FACING_NOTIFICATIONS)        if (permission.status !== 'granted') {            permission =await Permissions.askAsync(Permissions.USER_FACING_NOTIFICATION);            console.log("Permission Status: "+permission);            if (permission.status !== 'granted') {                Alert.alert('Permission not granted to show notifications!')            }        }        return permission;    }    async presentLocalNotification(date) {        await this.obtainNotificationPermission();        console.log("Permission Status: "+this.obtainNotificationPermission());        Notifications.presentLocalNotificationAsync({            title: 'Your Reservation',            body: 'Reservation for '+ date +' requested',            ios: {                sound: true            },            android: {                sound: true,                vibrate: true,                color: '#512DA8'            }        });    }
Viewing all 28469 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>