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

React Native: Add custom application functionality to Native Contacts Application

$
0
0

I have tried doing some research around this, but seem to keep getting Whatsapp FAQ's.

When I install Whatsapp on my Android device, then

  • Go to my Android contacts list.
  • Select a User.

I get a Whatsapp Badge on contacts, and there is call or message action, but may need a different use case in my app. How do I achieve this on React Native? Will it be possible on iOS?

I imagine its possible since Facebook uses RN for development?

enter image description here

(edit)

I did some digging and noticed that in he event I have multiple chat apps and view "Linked Contacts" its shows all the chat apps as linked contacts of each user on their platforms not sure if this provides more clarity.

Are they just searching my contact lists and linking that contact to the same copy of the contact they have? If so how would I do this?


How to open android app with full screen in React Native after getting push notification?

$
0
0

I need to open my android app in full screen after push notification without any touch or any interaction with app. But I need to realize this when the phone is locked or there is a password on it (if this is possible to do) Can someone help me to manage this part?

Notification sound disabled by default for new channel

$
0
0

Notification sound disabled by default when I did below:

Mobile used: Redmi note 7s

For every new channel that I tried creating, I cleared app data, uninstall app and then reinstall app(from USB). And when I tried local notification, it didnt show up with sound. So I checked settings, it says like attached image Screenshot_2019-11-12-13-06-33-807_com android settings

Code I used:

    const channel = new firebase.notifications.Android.Channel(
    'testabc994', 'testabc994', firebase.notifications.Android.Importance.Max)
    .setDescription('All notifications')
    .enableLights(true)
    .enableVibration(true)
    .setLockScreenVisibility(firebase.notifications.Android.Visibility.Public)
    .setSound("default");
    // Create the channel
    firebase.notifications().android.createChannel(channel);

Send notification code:

      const notification = new firebase.notifications.Notification({
        show_in_foreground: true
      })
      .setNotificationId('notificationId')
      .setTitle('My notification title')
      .setBody('My notification body')
      .setSound('default')
      .setData({
        key1: 'value1',
        key2: 'value2',
      });

      notification
        .android.setChannelId('testabc994')
        .android.setSmallIcon('ic_launcher')
        .android.setPriority(firebase.notifications.Android.Priority.High)
        .android.setGroupAlertBehaviour(firebase.notifications.Android.GroupAlert.All)
        .android.setCategory(firebase.notifications.Android.Category.Alarm)

      firebase.notifications().displayNotification(notification);

Android permissions I used in android manifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<uses-permission android:name="android.permission.VIBRATE" />

Any solution for this?

Photo upload on React Native Android produce Type Error Network Error

$
0
0

I'm executing a photo upload using the fetch API and I keep receiving Type Error Network Request Error. I receive the same error on the emulator and a device. I'm using react-native-image-crop-picker as the source for the photo upload data. Any thoughts?

const pathToURLImageUpload =  async (image: any, token: string) => {

      const { path, filename, mime } = image;

      const uri = path.replace("file://", "")
      const file = {
        uri,            
        type: mime,           
        name: filename             
      };

      const body = new FormData()
      body.append('file', file)

      const config = {
        method: 'POST', 
        headers: { 'Authorization': 'Bearer ' + token },
        body
      };

      return await fetch(`${<API URL>}/user/photo`, config)

}

RNFirebase core module was not found natively on Android, ensure you have correctly added the RNFirebase and Firebase gradle dependencies

$
0
0

I have this strange error for a hours and I can't fix it. I have all dependencies that I need.

Error

dependencies {
    implementation project(':react-native-firebase')
    implementation project(':react-native-code-push')
    implementation project(':react-native-sentry')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-iap')
    implementation project(':react-native-amplitude-analytics')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-ads:15.0.1"
    implementation "com.google.firebase:firebase-config:16.1.2"
    implementation "com.google.firebase:firebase-messaging:17.3.4"

    implementation "com.google.firebase:firebase-auth:9.6.1"
    implementation "com.google.firebase:firebase-database:9.6.1"

    implementation "com.google.firebase:firebase-messaging:17.3.0"
    implementation "com.google.firebase:firebase-core:16.0.3"
    implementation "com.google.firebase:firebase-auth:16.0.3"
    implementation "com.google.firebase:firebase-database:16.0.1"
}

Scroll multiple horizontal scrollview in sync when you scroll one in React Native

$
0
0

Below is a sample of what needs to be achieved in React Native:

Title1

Some description that spans horizontally using a ScrollView (horizontal prop)...............................

Title2

Some description that spans horizontally using a ScrollView (horizontal prop)...............................

Title3

Some description that spans horizontally using a ScrollView (horizontal prop)...............................

The code for the same is:

FlatList --> View --> Title + ScrollView (description)

Now, the expectation is when I scroll the description of one row, all the descriptions from the other row should scroll in sync.

Below is the structure:

<View>
    <TouchableOpacity>
      <View style={styles.titleContainer}>
        <Text style={styles.title}>{name}</Text>
      </View>
    </TouchableOpacity>

    <ScrollView
      onMomentumScrollEnd={e => this.onScroll(e, index)}
      ref={node => { this.scrollRef[index] = node; }}
      scrollEventThrottle={16}
      showsHorizontalScrollIndicator={false}
      horizontal
      style={styles.fundContainer}
    >
      <View style={styles.statsContainer}>
        <Text>Some Description</Text>
      </View>
    </ScrollView>
  </View>

And the method that I run on scroll:

  onScroll = (event: Object, index: number) => {
    this.scrollRef.forEach((scrollItem, scrollIndex) => {
      if (scrollIndex !== index) {
        scrollItem.scrollTo({
          x: event.nativeEvent.contentOffset.x,
          y: event.nativeEvent.contentOffset.y,
          animated: true,
        });
      }
    });
  };

I am using onMomentumScrollEnd which scrolls the item on scroll end. If I use onScroll, it creates a performance bottleneck and lags miserably.

Are there any workaround to scroll the list in sync?

React Native on Android: Unable to determine the current character, it is not a string, number, array, or object

$
0
0

I create a new application and insert a old code, when i build the application this error appears:

Script 'C:\Users\nameuser\Desktop\nameapp\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 191

What went wrong:

A problem occurred evaluating settings 'nameapp'.

Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'i' with an int value of 105
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
info Run "react-native --help" to see a list of all available commands.

With react-native info command I have the current situation:

info
  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
      Memory: 6.46 GB / 15.85 GB
    Binaries:
      Yarn: 1.15.2 - C:\laragon\bin\nodejs\node-v11\yarn.CMD
      npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5900203

And on the package.json:

{
  "name": "nameapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/cli-platform-android": "^2.9.0",
    "axios": "^0.18.0",
    "haversine": "^1.1.0",
    "moment": "^2.22.2",
    "react": "16.6.3",
    "react-native": "^0.59.8",
    "react-native-actionsheet": "^2.4.2",
    "react-native-auto-height-image": "^1.1.0",
    "react-native-cached-image": "^1.4.3",
    "react-native-cli": "^2.0.1",
    "react-native-fbsdk": "^0.8.0",
    "react-native-global-font": "^1.0.2",
    "react-native-google-places": "^3.0.5",
    "react-native-image-crop-picker": "^0.24.1",
    "react-native-image-pan-zoom": "^2.1.10",
    "react-native-image-placeholder": "^1.0.14",
    "react-native-iphone-x-helper": "^1.2.0",
    "react-native-keyboard-manager": "^4.0.13-10",
    "react-native-maps": "github:react-community/react-native-maps",
    "react-native-maps-super-cluster": "^1.4.1",
    "react-native-modal-datetime-picker": "^5.1.0",
    "react-native-open-maps": "^0.3.3",
    "react-native-progress": "^3.4.0",
    "react-native-push-notification": "^3.1.2",
    "react-native-router-flux": "^4.0.6",
    "react-native-share": "^1.2.1",
    "react-native-snap-carousel": "^3.7.4",
    "react-native-swiper": "^1.5.13",
    "react-native-vector-icons": "^4.6.0",
    "react-native-view-shot": "^2.5.0",
    "react-redux": "^5.0.7",
    "redux": "^3.7.2",
    "redux-persist": "^4.10.1",
    "redux-persist-transform-filter": "0.0.15",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./src/fonts"
    ]
  }
}

Thank for the help.

Android - Location Permission - reponse from alert box

$
0
0

enter image description here

Hello guys,

I'm developing an app using react native.

How can I know the value pressed for this alert box on Android ?

I would actually need to immediately listen to the response from that alert box to display a component on the screen in the background. If access is denied, I will show component X else component Y.

Thanks and Kind Regards, Avinash


React native OAuth2 redirect_uri: Invalid scheme

$
0
0

recently I've been learning about react native and I encountered a so farm unsolvable problem. I'm trying to authenticate using gmail OAuth2 from my app, as a redirect parameter I put myscheme://oauth the whole url looks like this:

https://accounts.google.com/o/oauth2/v2/auth?response_type=token&client_id=XXXXXXXX&redirect_uri=myscheme://oauth&scope=https://www.googleapis.com/auth/spreadsheets

I registered an intent-filter in my manifest.xml which looks like this:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:launchMode="singleTask"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="myscheme" android:host="oauth"/>
        </intent-filter>
      </activity>

I am using react native Linking to open the URL and the error I get (in the browser) is 400 Invalid parameter value for redirect_uri: Invalid scheme: myscheme://oauth

Can anyone help me what am I missing here?

adb server version (40) doesn't match this client (41); killing

$
0
0

Couldn't start project on Android: adb server version (40) doesn't match this client (41); killing... could not read OK from ADB Server * failed to start daemon adb.exe: failed to check server version: cannot connect to daemon

i have installed android platform development tools but it still doesn't work even after changing Genymotion settings to use my android Software development kit instead of its default android tools

Tabs into a component not tab navigation

$
0
0

I have to set a lot of informations befor setting two tabs for more details, like this: enter image description here

there is a tab component into a screen with other components. how can I do it ? I don't think I can use tab navigation, there is a third party lib for that ?

Can not save value in keystore in react native

$
0
0

i'm using react-native-secure-key-store library to save a value in the android Key Store. When the language of device set to English everything works fine. but when i change the language of device to "Arabic" or "Persian" i'm getting this error:

{"framesToPop": 1, "code": "EUNSPECIFIED"}

Any ideas why this happens? any help will be appreciated

How to adjust font size to fit view in React Native for Android?

$
0
0

How I can make the font size of the text auto change inside a view in react native?

I have text with different lengths, some of which doesn't fit the view so decreased the font size. I have checked the docs and found this but it's for iOS only and I need it for Android.

And does it work with other components like button and touchableopacity?

Android - push notification with NotificationCompat.Builder

$
0
0

I am modifying a react native plugin, since it seems that its author does not support and I need to correct an error.

The plugin is https://github.com/zo0r/react-native-push-notification and the custom audio does not work on android. I have modified the code and the code line where I put notification.setChannelId (NOTIFICATION_CHANNEL_ID_TMP); makes the custom audio works, but then the notification doesn't show inside app, it appears in the notification menu but not within the app.

If I comment on this line of code, the notification shows inside the app, but the default audio of the mobile phone rings.

I upload the code of the modified file in case someone wants to consult it. The modified line is 321

Code: https://repl.it/repls/BoldHumongousWorkers

Running React Native in WSL with the emulator running directly in Windows

$
0
0

I haven't done Android development in a while, so my knowledge of modern Android development is spotty.

I'm trying to learn React Native. I use WSL as my primary development environment. Since it'll probably be a pain to set up the Android emulator in Linux/WSL, I want to run the emulator directly on Windows. However, I'd prefer to be able to run react-native run-android in WSL.

How would I set up React Native to be able to run react-native run-android in WSL and run the app in an Android emulator on Windows?

My ANDROID_HOME variable should be set up correctly, but I don't know enough about Android to know if this is doing anything:

export ANDROID_HOME=/mnt/c/Users/Leo/AppData/Local/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

TouchableOpacity block during async calls #Performance React-native

$
0
0

i have fully working react-native android app Groww .Working on performance optimisation .

I am using Redux-saga & axios for async network call ,during network calls touchable opacity doesn't work ,everything work but clickable event doesn't responed.

I have optimised my application by using Flatlist , shouldComponentUpdate etc . but with this issue i am stuck any help would be appreciated.

React Native ActivityIndicator causing high CPU load and overheating

$
0
0

I'm using React Native component ActivityIndicator to display a preloading state. However, if this state persists for a few moments longer than expected (or app get stuck in the preloading state) my CPU starts to rapidly overload. You might think that this is due to some computation in the background, but this happens even when I just render it like this...

<View>
      <ActivityIndicator color="white" size="small"/>
      <Text>Connecting...</Text>
</View>

I'm using emulated device (S. Galaxy S6, API 23) in Genymotion emulator on Mac OSX 10.12.1 The process, which drains the CPU is Vboxheadless

enter image description here

Any ideas what might be causing this, or how to fix it? Am I doing something wrong or missing some settings?

React Native android: An absolute positioned, touchable element outside of the bounds of its parent is not clickable

$
0
0

I have a TouchableOpacity inside of a view. The view is small (height: 60) and the TouchableOpacity lies outside the bounds of its parent (position: absolute, top: 70). When the child is inside of the parent, i.e. top: 30, it's clickable, but when it's outside, it's not. And only the regions inside of the parent view are clickable (touch events pass through the regions out of bounds). Does anyone know of a way to register TouchableOpacity clicks even when it's outside the bounds of its parent?

Note that this works on iOS. It seems to only be a bug on android.

<View style={{height: 60, width: '100%', zIndex: 1}}>
    <TouchableOpacity onPress={() => console.log('pressed')} style={{position: 'absolute', zIndex: 2, backgroundColor: 'yellow', width: 100, height: 50, top: 70}} />
</View>

React Native android build failed. SDK location not found

$
0
0

I have error when i start running android

What went wrong:
A problem occurred evaluating project ':app'.  
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

How to set headers downloading a file using React Native and react-native-fs?

$
0
0

In order to download an asset an Authorization header needs to be set when using react-native-fs with React Native.

Following the documentation the header is set as such:

  const options = {
    headers: {
      Authorization: `Bearer ${accessToken}`,
    },
    fromUrl: url,
    toFile: path,
  };

  // const permission = await insurePermissions();

  const task = RNFS.downloadFile(options);

It works perfect in iOS however Android, using an emulator running either Android 6, 8, 9, or 10, the header isn't being sent so the server is instead returning a different asset with error because the user isn't being authenticated.

How is the Authentication header set in Android with react-native-fs?

Viewing all 28480 articles
Browse latest View live


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