MCPcopy Create free account
hub / github.com/transistorsoft/react-native-background-geolocation / sync

Function sync

example/Advanced/src/FABMenu.tsx:153–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

151 * BackgroundGeolocation.sync()
152 */
153 const sync = async () => {
154 try {
155 if (isSyncing) {
156 console.log('[FABMenu] Sync already in progress (ignored)');
157 return;
158 }
159
160 const count = await BackgroundGeolocation.getCount();
161
162 if (!count) {
163 Alert.alert('Sync', 'Locations database is empty');
164 return;
165 }
166
167 Alert.alert(
168 'Confirm Sync',
169 `Sync ${count} records?`,
170 [
171 { text: 'No', style: 'cancel' },
172 {
173 text: 'Yes',
174 onPress: async () => {
175 try {
176 setIsSyncing(true);
177 await BackgroundGeolocation.sync();
178 console.log('[FABMenu] Sync complete');
179 } catch (e) {
180 console.warn('[FABMenu] Sync error:', e);
181 Alert.alert('Sync error', String(e));
182 } finally {
183 setIsSyncing(false);
184 }
185 },
186 },
187 ],
188 { cancelable: true }
189 );
190 } catch (e) {
191 console.warn('[FABMenu] getCount/sync error:', e);
192 Alert.alert('Sync error', String(e));
193 }
194 };
195
196 /**
197 * BackgroundGeolocation.resetOdometer()

Callers 1

handleMenuItemPressFunction · 0.85

Calls 4

logMethod · 0.65
getCountMethod · 0.65
syncMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected