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

React Native app closes after saving a contact

$
0
0

I'm using react-native-contacts inside my react native app to save a contact.

Before saving I request WRITE permission from android.
It works, I open the contact form through my app and save it using the contact form. The contact is saving properly. But, after I have saved the contact, it goes to the home screen, not to my app.

I want to return to my app after the contact is saved.

here is my code,

saveContact = user => {
  var newPerson = {
    emailAddresses: [
      {
        label: "work",
        email: user.email
      }
    ],
    phoneNumbers: [
      {
        label: "mobile",
        number: user.mobileNumber
      }
    ],
    displayName: user.firstName + "" + user.lastName
  };

  PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS, {
    title: "Contacts",
    message: "This app would like to write contacts.",
    buttonPositive: "Please accept bare mortal"
  }).then(() => {
    Contacts.openContactForm(newPerson, (err, contact) => {
      if (err) throw err;
      // contact has been saved
    });
  });
};

Viewing all articles
Browse latest Browse all 29495

Trending Articles



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