Skip to content

Commit

Permalink
Merge pull request zingolabs#599 from juanky201271/dev_ios_sync_backg…
Browse files Browse the repository at this point in the history
…round

New approach for IOS Sync Background
  • Loading branch information
juanky201271 authored Feb 14, 2024
2 parents 82f35d1 + 5bae067 commit f4cc1cd
Show file tree
Hide file tree
Showing 7 changed files with 896 additions and 111 deletions.
2 changes: 2 additions & 0 deletions app/LoadedApp/LoadedApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ export class LoadedAppClass extends Component<LoadedAppClassProps, AppStateLoade
this.appstate = AppState.addEventListener('change', async nextAppState => {
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
//console.log('App has come to the foreground!');
// deactivate the interruption sync flag
await RPC.rpc_setInterruptSyncAfterBatch('false');
// reading background task info
if (Platform.OS === 'ios') {
// this file only exists in IOS BS.
Expand Down
8 changes: 4 additions & 4 deletions components/SyncReport/SyncReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>

useEffect(() => {
(async () => await RPC.rpc_setInterruptSyncAfterBatch('false'))();
setTimeout(() => setShowBackgroundLegend(false), 5000); // 5 seconds only
setTimeout(() => setShowBackgroundLegend(false), 10000); // 10 seconds only
}, []);

// ref: https://github.com/zingolabs/zingo-mobile/issues/327
Expand Down Expand Up @@ -219,7 +219,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>
/>
</View>
)}
{background.batches > 0 && background.date > 0 && showBackgroundLegend && (
{background.date > 0 && showBackgroundLegend && (
<View
style={{
display: 'flex',
Expand All @@ -230,8 +230,8 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>
<DetailLine
label={translate('report.lastbackgroundsync') as string}
value={
background.batches.toString() +
translate('report.batches-date') +
//background.batches.toString() +
//translate('report.batches-date') +
moment(Number(Number(background.date).toFixed(0)) * 1000).format('YYYY MMM D h:mm a')
}
/>
Expand Down
12 changes: 12 additions & 0 deletions ios/ZingoMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1F1CE02628C13DBD00A954D7 /* librustios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DB4DE513264B0EBA0084F17D /* librustios.a */; };
1F7D321D2B71D44800D2879C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F7D321C2B71D44800D2879C /* SystemConfiguration.framework */; };
1F7D32272B73DF3800D2879C /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F7D32262B73DF3800D2879C /* Reachability.m */; };
1F7D32282B73DF3800D2879C /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F7D32262B73DF3800D2879C /* Reachability.m */; };
1FE8E9AC296B85FC004A256B /* BackgroundTasks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */; };
5F9FEE8650525C4AF43859AB /* libPods-ZingoMobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1794449599A63970811D5CF0 /* libPods-ZingoMobile.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -45,6 +48,9 @@
1F26E03C28C0E45B009737D7 /* librustios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = librustios.a; path = "../rust/target/aarch64-apple-ios-sim/release/librustios.a"; sourceTree = "<group>"; };
1F70326429905E6A001D70A2 /* ZingoMobile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ZingoMobile.entitlements; path = ZingoMobile/ZingoMobile.entitlements; sourceTree = "<group>"; };
1F7638CA28BD7C3E0017F9B6 /* librustios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = librustios.a; path = ../rust/target/universal/release/librustios.a; sourceTree = "<group>"; };
1F7D321C2B71D44800D2879C /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
1F7D32252B73DF1600D2879C /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = ZingoMobile/Reachability.h; sourceTree = "<group>"; };
1F7D32262B73DF3800D2879C /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = ZingoMobile/Reachability.m; sourceTree = "<group>"; };
1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; };
57C30AB6DAB41A2ED2699835 /* libPods-ZingoMobile-ZingoMobileTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZingoMobile-ZingoMobileTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
65B24C2E2D48C83D6B5DDF6E /* Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; path = "Target Support Files/Pods-ZingoMobile-ZingoMobileTests/Pods-ZingoMobile-ZingoMobileTests.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,6 +78,7 @@
files = (
1FE8E9AC296B85FC004A256B /* BackgroundTasks.framework in Frameworks */,
5F9FEE8650525C4AF43859AB /* libPods-ZingoMobile.a in Frameworks */,
1F7D321D2B71D44800D2879C /* SystemConfiguration.framework in Frameworks */,
1F1CE02628C13DBD00A954D7 /* librustios.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -99,6 +106,8 @@
13B07FAE1A68108700A75B9A /* ZingoMobile */ = {
isa = PBXGroup;
children = (
1F7D32262B73DF3800D2879C /* Reachability.m */,
1F7D32252B73DF1600D2879C /* Reachability.h */,
1F70326429905E6A001D70A2 /* ZingoMobile.entitlements */,
DB4DE516264B103E0084F17D /* RPCModule.h */,
DB4DE517264B103E0084F17D /* RPCModule.m */,
Expand All @@ -115,6 +124,7 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
1F7D321C2B71D44800D2879C /* SystemConfiguration.framework */,
1FE8E9AB296B85FC004A256B /* BackgroundTasks.framework */,
DB4DE513264B0EBA0084F17D /* librustios.a */,
1F7638CA28BD7C3E0017F9B6 /* librustios.a */,
Expand Down Expand Up @@ -423,6 +433,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1F7D32282B73DF3800D2879C /* Reachability.m in Sources */,
00E356F31AD99517003FC87E /* ZingoMobileTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -433,6 +444,7 @@
files = (
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
DB4DE518264B103E0084F17D /* RPCModule.m in Sources */,
1F7D32272B73DF3800D2879C /* Reachability.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Loading

0 comments on commit f4cc1cd

Please sign in to comment.