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
    });
  });
};
Akila Devinda
  • 5,054
  • 3
  • 19
  • 35
Dimalka
  • 21
  • 4

1 Answers1

0

So I think you are talking about Callback when openContactForm when creation screen is closed

This issue is still OPEN on their github issue page and this feature is still not given by package owner.

For instance, you can see for iOS this thread

I think for now you need to add event listeners for both android and ios separately.

For more information about handling event listeners here

Akila Devinda
  • 5,054
  • 3
  • 19
  • 35