Commit 4e40f5e7 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

alert permission

parent 19de3b69
...@@ -154,7 +154,9 @@ ...@@ -154,7 +154,9 @@
"sendtoken": "Send Token", "sendtoken": "Send Token",
"itemnotfound": "There are no menu for this category", "itemnotfound": "There are no menu for this category",
"copyToClipboard": "Copied To Clipboard", "copyToClipboard": "Copied To Clipboard",
"accessNotPermitted": "Access Not Permitted!", "accessNotPermitted": "Click grant permission> allow all the time to grant location access",
"selectOpenSetting":"Allow",
"titleAlertLocationNotPermitted":"Location access is not permitted",
"tryItRealDevice": "Please use real device instead of emulator", "tryItRealDevice": "Please use real device instead of emulator",
"makeSureClaimCredit": "Claiming your old balance. Are you sure?", "makeSureClaimCredit": "Claiming your old balance. Are you sure?",
"notPremiumYet": "Your account is not yet a Premium Account", "notPremiumYet": "Your account is not yet a Premium Account",
......
...@@ -154,7 +154,9 @@ ...@@ -154,7 +154,9 @@
"sendtoken": "Kirim Token", "sendtoken": "Kirim Token",
"itemnotfound": "Tidak ada menu untuk kategori ini !", "itemnotfound": "Tidak ada menu untuk kategori ini !",
"copyToClipboard": "Disalin ke clipboard", "copyToClipboard": "Disalin ke clipboard",
"accessNotPermitted": "Akses tidak dizinkan!", "accessNotPermitted": "Klik Berikan izin > izinkan sepanjang waktu untuk memberikan akses lokasi",
"titleAlertLocationNotPermitted":"Permintaan izin lokasi tidak diberikan",
"selectOpenSetting":"Berikan izin",
"tryItRealDevice": "Mohon menggunakan device, bukan emulator", "tryItRealDevice": "Mohon menggunakan device, bukan emulator",
"makeSureClaimCredit": "Yakin akan mengambil saldo lama Anda?", "makeSureClaimCredit": "Yakin akan mengambil saldo lama Anda?",
"notPremiumYet": "Akun Anda belum menjadi Akun Premium", "notPremiumYet": "Akun Anda belum menjadi Akun Premium",
......
...@@ -5,7 +5,7 @@ import * as Location from 'expo-location'; ...@@ -5,7 +5,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions'; import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import * as React from 'react'; import * as React from 'react';
import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, PermissionStatus } from 'react-native';
import { Badge } from 'react-native-elements'; import { Badge } from 'react-native-elements';
import { SliderBox } from "react-native-image-slider-box"; import { SliderBox } from "react-native-image-slider-box";
import { Card } from 'react-native-shadow-cards'; import { Card } from 'react-native-shadow-cards';
...@@ -19,6 +19,7 @@ import CustomIosStatusBar from './CustomIosStatusBar'; ...@@ -19,6 +19,7 @@ import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
class Home extends React.Component { class Home extends React.Component {
...@@ -126,19 +127,33 @@ class Home extends React.Component { ...@@ -126,19 +127,33 @@ class Home extends React.Component {
this._unsubscribe(); this._unsubscribe();
} }
settings() {
this._getPermissions()
}
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
// Alert.alert('Akses tidak dizinkan!') Alert.alert(
Toast.show(i18n.t('accessNotPermitted')) i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.settings()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
// Alert.alert('Silahkan anda coba di real Device') // Alert.alert('Silahkan anda coba di real Device')
Toast.show(i18n.t('tryItRealDevice')) Toast.show(i18n.t('tryItRealDevice'))
} else { } else {
this._getCurrentPosisition() this._getCurrentPosisition()
} }
} }
_getCurrentPosisition = async () => { _getCurrentPosisition = async () => {
let location = await Location.getCurrentPositionAsync({ let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest accuracy: Location.Accuracy.Highest
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment