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

Opening a dynamic link from a WebView inside React native App

$
0
0

I am trying to open up a dynamic link from webview, where webview uri is pointed to a web app, which contains several components with links to be opened from the mobile app(Deep links to the app).

Right now I can open up the application from chrome browser in the emulator upon clicking the exact component( which opens up the app), but when I click the same component from the webview within the app it throws up the following error and App wont open up the page the deep link should open up.

Can't open url: intent://example.page.link/getapp#Intent;package=com.google.android.gms;action=com.google.firebase.dynamiclinks.VIEW_DYNAMIC_LINK;scheme=https;S.browser_fallback_url=https://play.google.com/store/apps/details%3Fid%3Dcom.ubercab;end;

My implementation is as follows,

WebApp

App.js

function App() {    return (<div><Button variant="primary">        Open this in your App</Button><Banner url={"https://testingapp.page.link/getapp"}/><Banner url={"https://testingapp.page.link/getapp"}/><Banner url={"https://testingapp.page.link/getapp"}/><Banner url={"https://testingapp.page.link/getapp"}/></div>  );}

Banner.js

const Banner=(props)=>{    const classes = useStyles();    const [expanded, setExpanded] = React.useState(false);    const styles = {        cardAction: {            display: 'block',            textAlign: 'initial',            height: '100%'        }    }  return (<div onClick={() => window.open(props.url, "_blank")}><Card className={classes.root}><CardMedia                  className={classes.media}                  image= {banner}                  title="Offer"              /></Card></div>  );        };export default Banner;

On the Mobile App side:

App.jsx

import React, { useEffect } from 'react';import { StyleSheet, Text, View, Button } from 'react-native';import dynamicLinks from '@react-native-firebase/dynamic-links';import { WebView } from 'react-native-webview';import { NavigationContainer } from '@react-navigation/native';import { createStackNavigator } from '@react-navigation/stack';function DetailsScreen({ navigation }) {  return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}><Text>Details Screen</Text></View>  );}function HomeScreen({ navigation }) {  async function buildLink() {    console.log('building link');    const link = await dynamicLinks().buildLink({      link: 'https://invertase.io',      // domainUriPrefix is created in your firebase console      domainUriPrefix: 'https://testingapp.page.link',      // optional set up which updates firebase analytics campaign      // "banner". This also needs setting up before hand      analytics: {        campaign: 'banner',      },    });    return link;  }  const handleDynamicLink = link => {    // Handle dynamic link inside your own application    console.log('Received URfffL:'+ link.url);    if (link.url === 'https://example.com/packageview') {      console.log('hit package view');      navigation.push('packageview');    }  };  useEffect(() => {    const unsubscribe = dynamicLinks().onLink(handleDynamicLink);    // When the is component unmounted, remove the listener    dynamicLinks()      .getInitialLink()      .then(link => {        console.log('Received URL:'+ link.url);        if (link.url === 'https://example.com/packageview') {          console.log('hit package view');          navigation.push('packageview');        }      });    return () => unsubscribe();  }, []);  return (   <WebView source={{ uri: 'http://10.0.2.2:3000/' }}/>     );}export default function App() {  const Stack = createStackNavigator();    return (<NavigationContainer><Stack.Navigator><Stack.Screen name="Home" component={HomeScreen} /><Stack.Screen name="packageview" component={DetailsScreen} /></Stack.Navigator></NavigationContainer>    );}const styles = StyleSheet.create({  container: {    flex: 1,    backgroundColor: '#fff',    alignItems: 'center',    justifyContent: 'center',  },});

Do anyone have any experience in anything related to this? On what's going wrong in here?


Read text from screen when other app is open?

$
0
0

I want to make an Android utility app that detects and saves addresses from the phone's screen. For example: when I scroll upon an address in Chrome, this app detects that and saves the address.

Determining what text is an address is not the problem for me. The problem is figuring out how to read the screen. I feel like it would be a security risk, so perhaps it is not possible.

React native TouchableOpacity onPress not working on Android

$
0
0

TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me.

My react-native version: 0.57.4

My code:

const initDrawer = navigation => (<TouchableOpacity    style={{ left: 16 }}    onPress={() => onPressDrawerButton(navigation)}><Ionicons name="ios-menu" color="white" size={30} /></TouchableOpacity>);

React-native app mesage read in oppo and vivo

$
0
0

strong textReact native app is facing the issue to read message automatically in vivo v15 and oppo model and working perfectly fine In other models

Build fails using React-Native-Bluetooth-Classic

$
0
0

I'm trying to use bluetooth in my app to stablish a serial connection. Once i add the React-Native-Bluetooth-Classic the app wont build. The following message pops:enter image description here

react-native: 0.61.4react-native-bluetooth-classic: 0.10.9

How to build Expo APK local

$
0
0

Is it possible to build the APK of an expo app locally?

The doc says:

If you haven’t used exp before, the first thing you’ll need to do is login with your Expo account using exp login.

I tried exp start, exp build:android but the commands require a login.

I don't want to build the APK using expo server. Is there a way to run this build locally? So no login and push of source code required?

If not, can I view the whole source code of the generated APK?

null is not an object (evaluating '_ExponentNotifications.default.cancelAllScheduledNotificationsAsync') React Native

$
0
0

I am getting this error when evaluating Notifications.cancelAllScheduledNotificationsAsync() in React Native application and android emulator.

Error Stack

 TypeError: null is not an object (evaluating '_ExponentNotifications.default.cancelAllScheduledNotificationsAsync')cancelAllScheduledNotificationsAsync@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:110086:44_callee$tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26262:23invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26438:32tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26262:23invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26338:30http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26368:19tryCallTwo@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27627:9doResolve@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27791:25Promise@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27650:14callInvokeWithMethodAndArg@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26367:33enqueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26372:157async@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26389:69tryCallOne@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27618:16http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27719:27_callTimer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31173:17_callImmediatesPass@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31209:19callImmediates@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31428:33callImmediates@[native code]__callImmediates@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3238:35http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3015:34__guard@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3221:15flushedQueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3014:21flushedQueue@[native code]invokeCallbackAndReturnFlushedQueue@[native code]

Notifications.js

import {Notifications} from 'expo'import * as Permissions from 'expo-permissions';import {AsyncStorage} from "react-native";const notificationsKey = "@questions-flash-cards-key:notifications";export function clearLocalNotifications() {    return AsyncStorage.removeItem(notificationsKey).then(() => Notifications.cancelAllScheduledNotificationsAsync())}const notification = {    title: "You forgot solving quiz today.",    body: "Answer quiz per day to improve yourself.",    ios: {        sound: true    },    android: {        sound: true,        vibrate: true,    },};export async function setLocalNotification() {    const {status} = await Permissions.getAsync(Permissions.NOTIFICATIONS);    if (status !== 'granted') {        await Permissions.askAsync(Permissions.NOTIFICATIONS);    }    AsyncStorage.getItem(notificationsKey).then(JSON.parse).then(async (data) => {        if (data === null) {            Notifications.cancelAllScheduledNotificationsAsync().then(() => {                let tomorrow = new Date(Date.now());                tomorrow.setDate(tomorrow.getDate() + 1);                tomorrow.setHours(12);                tomorrow.setMinutes(0);                Notifications.scheduleLocalNotificationAsync(notification, {                    time: tomorrow, repeat: "day"                })            })        }    })}

Grid Layout of View in React Native

$
0
0

I am trying to create a React Native View with a Layout like this one. How can I create a box, like one of the boxes on the image?

Is it possible to achieve this with Flex? I need one for the number (left), one for a text (right, top) and for another text (right, bottom)? They should be in the same order like on the image.


React Native missing java main class

$
0
0

I come from JS background and know a thing or two about react-native.

I was learning Android from tutorial point and in one of the points, they have mentioned

public static void main(String args[]) − Java program processing starts from the main() method which is a mandatory part of every Java program.

So, I opened RN project in node_module (boiler plate cli-code) and looked for reference of main( to find the processing of the file when I run react-native run-android but unfortunately wasn't able to find any such class in .java function

So can someone explain me what happens behind the scene when I do react-native run-android

Programmatically Restart a React Native App

$
0
0

Is it possible to programmatically restart a React Native app without writing any native code?

For instance, I know from the answer to this question that I can restart an Android app with:

Intent i = getBaseContext().getPackageManager()         .getLaunchIntentForPackage( getBaseContext().getPackageName() );i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);startActivity(i);

Can I do the same with React Native?

react-native-iap returns different subscription

$
0
0

I have implemented react-native-iap in my mobile app. I have added subscriptions under In app products on google play console. But whenever I am trying to retrive that subscriptions through js on getSubscriptions() I am getting different subscription. What will be the issue?

Open a modal on BottomTabNavigator click react-native

$
0
0

I was trying to open a modal from bottomnavigator , was following this tutorial - https://snack.expo.io/SyJKMkFUMI am using react-navigation -3.0.9

here is my app.js class App extends React.Component {

 renderItem = (route, index) => {     const {         navigation,         jumpToIndex,     } = this.props;     const isCapture = route.routeName === 'Capture';     const focused = index === navigation.state.index;     return (<TouchableWithoutFeedback             key={route.key}             onPress={() => isCapture ? this.props.navigation.navigate('CaptureModal') : jumpToIndex(index)}><View ><Text >{route.routeName}</Text></View></TouchableWithoutFeedback>     ); }; render() {     const {         navigation,     } = this.props;     const {         routes,} = navigation.state;       return (<View style={styles.container}>             {routes && routes.map(this.renderItem)}</View>     );}}   const Screen = (props) => (<View ><Text>{props.title} Screen</Text></View>    );    const styles = StyleSheet.create({       container: {       flex: 1,        backgroundColor: '#fff',       },        });      const TabNavigator = createBottomTabNavigator({      Home: {    screen: HomeScreen},Link: {    screen: LinksScreen},settings: {    screen: View,}, });   const CaptureStack = createStackNavigator({   Capture: {    screen: (props) => <Screen title="Capture" {...props} />,    navigationOptions: ({ navigation }) => ({        headerTitle: 'Capture',        headerLeft: (<Button                title="Back"                onPress={() => navigation.goBack(null)}            />),}),},})      const RootStack1 = createStackNavigator({     Main: {    screen: TabNavigator,       },        CaptureModal: {    screen: CaptureStack,    navigationOptions: {        gesturesEnabled: false,        },      },     }, {headerMode: 'none',mode: 'modal',   });

const AppNavigator = createAppContainer(RootStack1); export default AppNavigator;

Could anyone please explain what is wrong with this ? Could it be a routing version issue as the tutorial is using 1.0.0 .

Manifest Merger Failed issue in React Native Android

$
0
0

I am trying to run the React Native Application on my Android device but i am getting an error says "Manifest merger failed" , i have tried a lot to solve the issue but i am not getting any working solution please have a look on the attached Screenshot and suggest a solution , Thanks.

enter image description here

Develop clone same like Anydesk or Teamviewer for Android [closed]

$
0
0

From last some of the days I tried to find out some information/demo related to develop an android app same like AnyDesk or TeamViewer for online assistant. we found that the 2 android device connect using local network using socket programming, but i need the help for developing app like remote assistant(AnyDesk or Teamviewer) which work over live server not on socket server.

Any 3rd party SDK or API provide this type of feature it would be nice.

If anyone help me out for developing this in any programming language like Flutter,React-Native,Java it would be great help to me.

EdgeLight: Screen borders are not going beyond the notch and softkeys in react native

$
0
0

I am just trying to implement "edge light" Ref in react native.

I have this below code to achieve it.

<Layout style={{ flex: 1, paddingTop: 18, paddingBottom: 18, paddingLeft: 28, paddingRight: 28, borderWidth: 10, borderColor: '#36ABA5', justifyContent: 'center', backgroundColor: '#000', color: '#fff' }}> // All my code </Layout>

This seems to be working fine for the mobiles which are having straigh screens. But I am facing 2 issues,

  1. The same is not working when the mobile has notch or the mobile's softkeys are enabled.
  2. In Honor 8x the border itself is not coming when softkeys are disabled, when those are enabled, the border comes above the softkeys.

I tried calculating the window height, screen height and put the border. It seems to be not happening.

In Straight phone

In Straight phone:

In Notch phone:

In Notch phone:

In Softkeys enabled:

enter image description here

In Softkeys disabled:

In Softkeys disabled:

Wanted similar to this, but not colorful/ Expected Results:

Wanted similar to this, but not colorful/ Expected Results:


How Do I Bring A React Native Android App To The Foreground When It Is In The Background Or Has Been Killed?

$
0
0

Is there any way to bring a React Native app to the foreground when it is in the background or has been killed?

I have tried using react-native-invoke-app but it is no longer being maintained and only supports Android versions < 9.

Many thanks in advance!

Compile error Unable to resolve module graphql in React Native

$
0
0

I can't compile my project because of this error:

Error: Unable to resolve module ../jsutils/defineToStringTag fromnode_modules\graphql\language\source.js:

None of these files exist: * node_modules\graphql\jsutils\defineToStringTag(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) * node_modules\graphql\jsutils\defineToStringTag\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) at ModuleResolver.resolveDependency (F:\React\upTaskNative\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15) at ResolutionRequest.resolveDependency (F:\React\upTaskNative\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (F:\React\upTaskNative\node_modules\metro\src\node-haste\DependencyGraph.js:287:16) at Object.resolve (F:\React\upTaskNative\node_modules\metro\src\lib\transformHelpers.js:267:42) at F:\React\upTaskNative\node_modules\metro\src\DeltaBundler\traverseDependencies.js:434:31 at Array.map () at resolveDependencies (F:\React\upTaskNative\node_modules\metro\src\DeltaBundler\traverseDependencies.js:431:18) at F:\React\upTaskNative\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33 at Generator.next () at asyncGeneratorStep (F:\React\upTaskNative\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)

This error appeared when installing graphql dependencies with:

npm i graphql

These are the dependencies in package.json:

"dependencies": {"@apollo/client": "^3.0.0-beta.44","@react-native-community/masked-view": "^0.1.10","@react-navigation/native": "^5.3.0","@react-navigation/stack": "^5.3.3","apollo-cache-inmemory": "^1.6.6","apollo-link-http": "^1.5.17","graphql": "^15.0.0","native-base": "^2.13.12","react": "16.11.0","react-native": "0.62.2","react-native-gesture-handler": "^1.6.1","react-native-reanimated": "^1.8.0","react-native-safe-area-context": "^1.0.0","react-native-screens": "^2.7.0"  },

I don't know what could be the problem.

I don't get the result of my promice despite using await

$
0
0

My function looks like this:

async function getPlaceForecast(lat, long) {//var response;var day5forecast = 'http://api.openweathermap.org/data/2.5/forecast?lat='+ lat +'&lon='+ long +'&appid='+ apikey;try {    const request = new Request(tmp2, {        method: 'get'    })    let response = await fetch(request)        .then(value => {            console.log("than", value.json());            return value//.json();        })        .catch(function (error) {            console.error(error);        });}catch{}//return response;

}

This is the result:

'than', { _40: 0, _65: 0, _55: null, _72: null }

And this is the result without using .json() :

'than', { type: 'default', status: 200, ok: true, statusText: undefined, headers: { map: { 'access-control-allow-methods': 'GET, POST','access-control-allow-credentials': 'true','access-control-allow-origin': '*','x-cache-key': '/data/2.5/forecast?lat=28.35&lon=-14.05', connection: 'keep-alive','content-length': '14383','content-type': 'application/json; charset=utf-8', server: 'openresty' } }, url: 'http://api.openweathermap.org/data/2.5/forecast?lat=28.349414&lon=-14.046311&appid=', _bodyInit: { _data: { size: 14383, offset: 0, blobId: '2dbf82c5-5d28-47db-9034-7f239bf8290a' } }, _bodyBlob: { _data: { size: 14383, offset: 0, blobId: '2dbf82c5-5d28-47db-9034-7f239bf8290a' } } }

What did I do wrong?

React - The method or property expo-file-system.downloadAsync is not available on android

$
0
0

I'm running my react native app on android and i've got this following error

WARN  Possible Unhandled Promise Rejection (id: 11):Error: The method or property expo-file-system.downloadAsync is not available on android, are you sure you've linked all the native dependencies properly?construct@[native code]_construct@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25927:28Wrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25882:25construct@[native code]http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:100178:302CodedError@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:100191:26construct@[native code]http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:100221:302UnavailabilityError@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:100232:25downloadAsync$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:102292:48tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26271:23...

Furthermore all my icons are gone. Does anyone know how to handle this? Thanks.

How to pass data between react native screens?

$
0
0

Hey I am new to react native. So basically I have a stack navigator with two screen option: Screen 1 (Default) and Screen2. I already set up a button so that when pressed it will take me to Screen 2. So in Screen1 I have an array displayed as scrollview component. Now when i press the button to go to screen2 I want to pass some of the array values to that screen2 component. What is the best way to do it? Thank you :)

I am really new so my attempts are kinda dumb. I tried importing the Screen1 component and calling the array values via this.state but no access.

Viewing all 28467 articles
Browse latest View live


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