You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If granted is false, this popup will be triggered every time it is called:
If granted is true, the popup won't appear anymore until the permissions are revoked.
Code snippets
Checking for permissions and then requesting permissions:
const{ granted }=awaitContacts.getPermissionsAsync();if(granted){doWorkOnContactList()}elseif(!granted&&shouldAskForPermission){// shouldAskForPermission will depend on business logicconst{ granted }=awaitContacts.requestPermissionsAsync();if(granted){doWorkOnContactList()}}
Contacts data structure:
const{ data }=awaitContacts.getContactsAsync({fields: [Contacts.Fields.PhoneNumbers],});console.log("Number of contacts:",data.length);for(vari=0;i<Math.min(data.length,100);i++){if(data[i]&&data[i].name&&data[i].phoneNumbers){console.log(`${data[i].name}: ${data[i].phoneNumbers[0].number}`);}}
Comments
I suspect we will need to store some state (maybe in local storage or on the server) about whether we have asked for contact permissions before. If a user denies permissions initially, we don't want don't want to keep asking every time the app re-renders. But we do want the ability to ask again if they click the wrong thing, or if they decide they want to enable the friends functionality down the track.
The text was updated successfully, but these errors were encountered:
Access via Settings: On your comment about a user accidentally not granting permission access, perhaps this can be an option on our Settings page. With that, we can provide some informational text to explain why we need contact access.
Table naming: A suggestion on the "Friendship" table - I have an inkling naming it something a bit more generic like "Relationship" will give us more flexibility in future.
Blocking a contact: Are we going to give users the access to "block" other contacts, i.e. the WhatsApp pattern? I think from what you've described it makes sense to keep it as simple as "User 1 is friends with User 2" or "User 1 is not friends with User 2".
Navigation bar: Just raising a thought if the Contacts page sits within our navigation bar or somewhere else
Suggestions
Contacts API
Contacts.getPermissionsAsync()
When permission hasn't been granted yet, revoked, or denied:
When permission has been granted:
Contacts.requestPermissionsAsync()
If
granted
is false, this popup will be triggered every time it is called:If
granted
is true, the popup won't appear anymore until the permissions are revoked.Code snippets
Checking for permissions and then requesting permissions:
Contacts data structure:
Comments
The text was updated successfully, but these errors were encountered: