File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 22
33import deviceInfo from 'react-native-device-info'
44import networkInfo from 'react-native-network-info'
5+ import { Platform } from 'react-native'
56import pkg from '../../../package.json'
67
78export const getIpAddress = ( ) : Promise < ?string > =>
@@ -14,13 +15,17 @@ export const getIpAddress = (): Promise<?string> =>
1415 } )
1516
1617export const getPosition = ( args : any = { } ) : Promise < Object > =>
17- new Promise ( resolve => {
18- navigator . geolocation . getCurrentPosition ( resolve , ( ) => resolve ( { } ) , {
19- ...args ,
20- enableHighAccuracy : true ,
21- maximumAge : 1000 /*ms*/ ,
22- timeout : 5000 /*ms*/ ,
23- } )
18+ new Promise ( ( resolve , reject ) => {
19+ if ( Platform . OS === 'android' ) {
20+ navigator . geolocation . getCurrentPosition ( resolve , reject )
21+ } else {
22+ navigator . geolocation . getCurrentPosition ( resolve , reject , {
23+ ...args ,
24+ enableHighAccuracy : true ,
25+ maximumAge : 1000 /* ms */ ,
26+ timeout : 15000 /* ms */ ,
27+ } )
28+ }
2429 } )
2530
2631export const collectData = async ( ) => ( {
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {Error, ErrorMessage} from './components'
1111import { getPosition , collectData , reportToServer } from './wifi-tools'
1212import { styles } from './tool'
1313import type { ToolOptions } from './types'
14+ import bugsnag from '../../bugsnag'
1415
1516export const toolName = 'wifi'
1617
@@ -49,7 +50,13 @@ export class ToolView extends React.Component<Props, State> {
4950 }
5051
5152 this . setState ( ( ) => ( { status : 'collecting' , error : '' } ) )
52- const [ position , device ] = await Promise . all ( [ getPosition ( ) , collectData ( ) ] )
53+ const [ position , device ] = await Promise . all ( [
54+ getPosition ( ) . catch ( error => {
55+ bugsnag . notify ( error )
56+ return null
57+ } ) ,
58+ collectData ( ) ,
59+ ] )
5360 this . setState ( ( ) => ( { status : 'reporting' } ) )
5461
5562 try {
You can’t perform that action at this time.
0 commit comments