Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-device-info
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-device-info
Commits
26a5615f
Commit
26a5615f
authored
Oct 06, 2018
by
Diego Mello
Committed by
Mehdi Achour
Oct 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add hasNotch() (#500)
parent
e5abc1bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
0 deletions
+133
-0
README.md
README.md
+13
-0
deviceinfo.d.ts
deviceinfo.d.ts
+1
-0
deviceinfo.js
deviceinfo.js
+118
-0
deviceinfo.js.flow
deviceinfo.js.flow
+1
-0
No files found.
README.md
View file @
26a5615f
...
...
@@ -233,6 +233,7 @@ import DeviceInfo from 'react-native-device-info';
|
[
isEmulator()
](
#isemulator
)
|
`boolean`
| ✅ | ✅ | ✅ | ? |
|
[
isPinOrFingerprintSet()
](
#ispinorfingerprintset
)
| (callback)
`boolean`
| ✅ | ✅ | ✅ | 0.10.1 |
|
[
isTablet()
](
#istablet
)
|
`boolean`
| ✅ | ✅ | ✅ | ? |
|
[
hasNotch()
](
#hasNotch
)
|
`boolean`
| ✅ | ✅ | ✅ | ? |
---
...
...
@@ -833,6 +834,18 @@ Tells if the device is a tablet.
const
isTablet
=
DeviceInfo
.
isTablet
();
// true
```
---
### hasNotch()
Tells if the device has a notch.
**Examples**
```
js
const
hasNotch
=
DeviceInfo
.
hasNotch
();
// true
```
## Troubleshooting
When installing or using
`react-native-device-info`
, you may encounter the following problems:
...
...
deviceinfo.d.ts
View file @
26a5615f
...
...
@@ -26,6 +26,7 @@ declare const _default: {
getFontScale
:
()
=>
number
;
is24Hour
:
()
=>
boolean
;
isPinOrFingerprintSet
:
(
cb
:
(
isPinOrFingerprintSet
:
boolean
)
=>
void
)
=>
void
;
hasNotch
:
()
=>
boolean
;
getFirstInstallTime
:
()
=>
number
;
getLastUpdateTime
:
()
=>
number
;
getSerialNumber
:
()
=>
string
;
...
...
deviceinfo.js
View file @
26a5615f
...
...
@@ -9,6 +9,121 @@ if (!RNDeviceInfo && Platform.OS === 'web') {
RNDeviceInfo
=
require
(
'./web'
);
}
const
devicesWithNotch
=
[
{
brand
:
'Apple'
,
model
:
'iPhone X'
,
},
{
brand
:
'Apple'
,
model
:
'iPhone XS'
,
},
{
brand
:
'Apple'
,
model
:
'iPhone XS Max'
,
},
{
brand
:
'Apple'
,
model
:
'iPhone XR'
,
},
{
brand
:
'Asus'
,
model
:
'ZenFone 5'
,
},
{
brand
:
'Asus'
,
model
:
'ZenFone 5z'
,
},
{
brand
:
'Huawei'
,
model
:
'P20'
,
},
{
brand
:
'Huawei'
,
model
:
'P20 Plus'
,
},
{
brand
:
'Huawei'
,
model
:
'P20 Lite'
,
},
{
brand
:
'Huawei'
,
model
:
'Honor 10'
,
},
{
brand
:
'Huawei'
,
model
:
'Nova 3'
,
},
{
brand
:
'Huawei'
,
model
:
'Nova 3i'
,
},
{
brand
:
'Oppo'
,
model
:
'R15'
,
},
{
brand
:
'Oppo'
,
model
:
'R15 Pro'
,
},
{
brand
:
'Oppo'
,
model
:
'F7'
,
},
{
brand
:
'Vivo'
,
model
:
'V9'
,
},
{
brand
:
'Vivo'
,
model
:
'X21'
,
},
{
brand
:
'Vivo'
,
model
:
'X21 UD'
,
},
{
brand
:
'OnePlus'
,
model
:
'6'
,
},
{
brand
:
'OnePlus'
,
model
:
'A6003'
,
},
{
brand
:
'OnePlus'
,
model
:
'OnePlus A6003'
,
},
{
brand
:
'LG'
,
model
:
'G7'
,
},
{
brand
:
'LG'
,
model
:
'G7 ThinQ'
,
},
{
brand
:
'LG'
,
model
:
'G7+ ThinQ'
,
},
{
brand
:
'Leagoo'
,
model
:
'S9'
,
},
{
brand
:
'Oukitel'
,
model
:
'U18'
,
},
{
brand
:
'Sharp'
,
model
:
'Aquos S3'
,
},
{
brand
:
'Nokia'
,
model
:
'6.1 Plus'
,
},
];
export
default
{
getUniqueID
:
function
()
{
return
RNDeviceInfo
.
uniqueId
;
...
...
@@ -91,6 +206,9 @@ export default {
isPinOrFingerprintSet
:
function
()
{
return
RNDeviceInfo
.
isPinOrFingerprintSet
;
},
hasNotch
:
function
()
{
return
devicesWithNotch
.
findIndex
(
item
=>
item
.
brand
===
RNDeviceInfo
.
brand
&&
item
.
model
===
RNDeviceInfo
.
model
)
!==
-
1
;
},
getFirstInstallTime
:
function
()
{
return
RNDeviceInfo
.
firstInstallTime
;
},
...
...
deviceinfo.js.flow
View file @
26a5615f
...
...
@@ -27,6 +27,7 @@ declare module.exports: {
isPinOrFingerprintSet: () => (
cb: (isPinOrFingerprintSet: boolean) => void
) => void,
hasNotch: () => boolean,
getFirstInstallTime: () => number,
getLastUpdateTime: () => number,
getSerialNumber: () => string,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment