maniac-tech / maniac-tech/react-native-expo-read-sms

`status === PermissionAndroid.RESULTS.GRANTED` would be checking text against an object.

Open
#79 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue question
Dominant language
Java
Stars
85
Forks
32
PR merge metrics
No merged PRs in 30d

Description

from what I have seen, status in this case would return

```
{
"android.permission.RECEIVE_SMS": "granted",
"android.permission.READ_SMS": "denied"
}
```

so `status === PermissionAndroid.RESULTS.GRANTED` would be checking text against an object.

this can be rewritten as:

```
const status = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.RECEIVE_SMS,
PermissionsAndroid.PERMISSIONS.READ_SMS,
]);

const granted = PermissionsAndroid.RESULTS.GRANTED;
const denied = PermissionsAndroid.RESULTS.DENIED;
const neverAskAgain = PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN;

if (status[PermissionsAndroid.PERMISSIONS.RECEIVE_SMS] === granted &&
status[PermissionsAndroid.PERMISSIONS.READ_SMS] === granted) {
return true;
}

if ([status[PermissionsAndroid.PERMISSIONS.RECEIVE_SMS], status[PermissionsAndroid.PERMISSIONS.READ_SMS]].includes(denied)) {
console.log("Read/Receive SMS permission denied by user.", status);
} else if ([status[PermissionsAndroid.PERMISSIONS.RECEIVE_SMS], status[PermissionsAndroid.PERMISSIONS.READ_SMS]].includes(neverAskAgain)) {
console.log("Read/Receive SMS permission revoked by user.", status);
}
```

_Originally posted by @alokpant in https://github.com/maniac-tech/react-native-expo-read-sms/pull/76#discussion_r1863434353_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the permission-handling code discussed in the issue and inspect the requestMultiple result against the listed RECEIVE_SMS and READ_SMS permissions. Done means the code checks both returned permission values individually and distinguishes granted, denied, and never-ask-again; no file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.