Closed rajanrai93 closed 6 years ago
Hey @rajanrai93 - before I recreate and debug this - have you confirmed that the contactIdentifer exists? It looks like you're first setting the identifier and I'm not 100% sure that this works. I think Apple provides the identifier on creation and then we can use it for both updating and deleting. But at contact creation time, I don't think it can be provided. I might be wrong about that, but please try:
If it still crashes, let me know.
UPDATE: Looking at your code again it doesn't appear you set the identifier (you just seem to declare it twice), but the question still stands - is that a contact identifier that exists for one of your contacts? If you can confirm that, we can then look deeper.
As always, please also post your debug logs so we can read what the error is.
Paul
You're absolutely right! can't set a contact id. just thought it would have been an easier way to fetch the id. So if we're trying to fetch the ID after the contact is created to use it in the future(deleting contact in app), we would just use a state prop?
@rajanrai93 Totally depends on what your app's requirements are - but yes!
When adding, you will receive back the contact with the newly created identifier and you can store it, if you're going to act on it right away. Or you can later query your contacts (either get all of them or search for a specific one) and get the IDs at that time, then do something. Basically once the contact is created, the identifier is returned at all times and you can then act on it using the identifier.
In one case that I use, I show a list of all contacts to my users. When the user clicks on a contact, I then store that one specific user's data in state. When manipulating, I refer to that.
Paul
I've been able to allow the user to input what they want the contact name and number to be in my app and add the contact, but when they want to delete the contact, the app crashes. I'm not sure if theres an issue with the library or not, it seems to not read the contact identifier properly. I've asked on SO but no answer :( I apologize if there is just a stupid error in my code.