morenoh149 / react-native-contacts

React Native Contacts
MIT License
1.64k stars 560 forks source link

App crashes when trying to add a contact from app only on Testflight, working ok running locally. #625

Closed aaronlugo closed 3 years ago

aaronlugo commented 3 years ago

I'm using a function like this:

Contacts.checkPermission()
      .then(permission => {
        // Contacts.PERMISSION_AUTHORIZED || Contacts.PERMISSION_UNDEFINED || Contacts.PERMISSION_DENIED
        if (permission === 'undefined') {
          Contacts.requestPermission()
            .then(response => {
              console.log('Response', response);
              if (response === 'authorized') {
                Contacts.addContact(contact)
                  .then(result => {
                    return Alert.alert('Contact Added!', [{text: 'OK'}]);
                  })
                  .catch(e => {
                    console.log('Something Wrong Getting contacts', e);
                    return Alert.alert(
                      'Sorry, something went wrong',
                      'Sorry, We could not access your contacts list.',
                      [{text: 'OK'}],
                    );
                  });
              }
            })
            .catch(er => {
              console.log('Permission Error', er);
            });
        }
        if (permission === 'authorized') {
          Contacts.requestPermission()
            .then(response => {
              console.log('Response', response);
              if (response === 'authorized') {
                Contacts.addContact(contact)
                  .then(result => {
                    return Alert.alert('Contact Added!', [{text: 'OK'}]);
                  })
                  .catch(e => {
                    console.log('Something Wrong Getting contacts', e);
                    return Alert.alert(
                      'Sorry, something went wrong',
                      'Sorry, We could not access your contacts list.',
                      [{text: 'OK'}],
                    );
                  });
              }
            })
            .catch(er => {
              console.log('Permission Error', er);
            });
        }
        if (permission === 'denied') {
          Alert.alert(
            'Permission Denied',
            'If you want to add new contacts, Go to Settings > Inthority > Contacts and grant permission to acces contacts',
            [{text: 'OK'}],
          );
          console.log('Sorry you did not gave permission to add new contacts');
        }
      })
      .catch(err => {
        console.log(err);
        Alert.alert(
          'Sorry, something went wrong',
          'Sorry, We could not access your contacts list.',
          [{text: 'OK'}],
        );
      });

In my info.plist I have set the Privacy - Contacts Usage Description description like this AppName Would like to access your contacts to sync them with your Client List and Add new contacts

github-actions[bot] commented 3 years ago

This issue is stale, please provide more information about the status

mannyuiux commented 10 months ago

I'm facing the same issue. Do we have any workaround for this?