-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.plugin.js
More file actions
36 lines (28 loc) · 920 Bytes
/
app.plugin.js
File metadata and controls
36 lines (28 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { withAndroidManifest } = require('@expo/config-plugins');
const withSMSRetriever = (config) => {
return withAndroidManifest(config, (config) => {
const androidManifest = config.modResults;
if (!androidManifest.manifest) {
androidManifest.manifest = {};
}
if (!androidManifest.manifest['uses-permission']) {
androidManifest.manifest['uses-permission'] = [];
}
const permissions = [
'android.permission.RECEIVE_SMS',
'android.permission.READ_SMS',
];
permissions.forEach((permission) => {
const hasPermission = androidManifest.manifest['uses-permission'].some(
(p) => p.$['android:name'] === permission
);
if (!hasPermission) {
androidManifest.manifest['uses-permission'].push({
$: { 'android:name': permission },
});
}
});
return config;
});
};
module.exports = withSMSRetriever;