Open tgreco opened 3 years ago
Happen to me too, very weird if i donwload the apk i uploaded to play store and install that it works fine, but if install the app from google play store it hangs after BackgroundGeolocation.start(). Please Help production app is not working
Plugin version: 0.6.3
Platform: Android
OS version: 11
Device manufacturer and model: Pixel 3
React Native version: 0.64.2
Plugin configuration options:
export class HomeScreen extends PureComponent<IHomeScreen, State> {
constructor(props: IHomeScreen) {
super(props);
this.state = { error: undefined, selectedId: null };
}
componentDidMount() {
BackgroundGeolocation.configure({
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 50,
distanceFilter: 50,
notificationTitle: 'Background tracking',
notificationText: 'enabled',
debug: true,
startOnBoot: false,
stopOnTerminate: true,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
interval: 1000 * 15, // * 60,
fastestInterval: 5000,
activitiesInterval: 10000 * 10,
stopOnStillActivity: false,
url: 'http://192.168.81.15:3000/location',
httpHeaders: {
'X-FOO': 'bar',
},
// customize post properties
postTemplate: {
lat: '@latitude',
lon: '@longitude',
foo: 'bar', // you can also add your own properties
},
});
BackgroundGeolocation.on('location', (_location: any) => {
console.log('loc after 15 minutes', _location);
// handle your locations here
// to perform long running operation on iOS
// you need to create background task
BackgroundGeolocation.startTask(taskKey => {
// execute long running task
// eg. ajax post location
// IMPORTANT: task has to be ended by endTask
BackgroundGeolocation.endTask(taskKey);
});
});
BackgroundGeolocation.on('authorization', status => {
console.log('[INFO] BackgroundGeolocation authorization status: ' + status);
if (status !== BackgroundGeolocation.AUTHORIZED) {
// we need to set delay or otherwise alert may not be shown
setTimeout(
() =>
Alert.alert('App requires location tracking permission', 'Would you like to open app settings?', [
{ text: 'Yes', onPress: () => BackgroundGeolocation.showAppSettings() },
{ text: 'No', onPress: () => console.log('No Pressed'), style: 'cancel' },
]),
3000,
);
}
});
BackgroundGeolocation.checkStatus(status => {
console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);
console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled);
console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization);
// you don't need to check status before start (this is just the example)
if (!status.isRunning) {
BackgroundGeolocation.start(); //triggers start on start event
}
});
// you can also just start without checking for status
BackgroundGeolocation.start();
}
componentWillUnmount() {
// unregister all event listeners
BackgroundGeolocation.removeAllListeners();
}
componentDidCatch(error: Error, errorInfo: any) {
this.setState({
error: error,
errorInfo: errorInfo,
});
console.log('[JS-EXCEPTION]: ', error, errorInfo);
}
formOnSubmit = async (values: any) => {
console.log('DEVK value: ', values);
};
onPressSort = () => {
console.log('DEVKXXX');
};
handleOnPress = (item: any) => {
console.log(item);
this.props.navigation.navigate(item.route_name);
};
renderItem = ({ item, index }: { item: any; index: number }) => {
return item.subcategory.length ? (
<DView style={styles.dView}>
<DView style={styles.title}>
<DText style={{ color: colors.chromatic, fontSize: variants.title, fontWeight: 'bold' }}>
{item.category_name}
</DText>
</DView>
<DView style={styles.dRow}>
{item.subcategory.map((menu: any) => {
return (
<TouchableOpacity onPress={() => this.handleOnPress(menu)}>
<DView style={item.category_name ? styles.dCell : styles.dCellNoCate}>
<DVectorIcons
provider="MaterialIcons"
style={styles.iconStyles}
name={menu.icon_name}
color={colors.darkBg}
size={32}
/>
<DText style={styles.cellTitle}>{menu.val}</DText>
</DView>
</TouchableOpacity>
);
})}
</DView>
</DView>
) : (
<></>
);
};
render() {
return (
<DContainer style={styles.dContainer}>
<DFlatList data={MENU} renderItem={this.renderItem} />
</DContainer>
);
}
}
Context App not responding!
Your Environment
Context
This was working for the longest time but all of a sudden the production app on the Play Store started hanging.
Expected Behavior
Location works.
Actual Behavior
ANR executing service com.mycompany.appname/com.marianhello.bgloc.service.LocationServiceImpl