Skip to content

Commit ec69835

Browse files
dacharyccbullinger
andauthored
(DOCSP-33996): Swift: Update progress notification documentation (#3244)
## Pull Request Info Jira ticket: https://jira.mongodb.org/browse/DOCSP-33996 - [Manage Sync Sessions](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-33996/sdk/swift/sync/sync-session/#check-upload---download-progress-for-a-sync-session): Add a text description with some details. Update code examples. ### Reminder Checklist Before merging your PR, make sure to check a few things. - [x] Did you tag pages appropriately? - genre - meta.keywords - meta.description - [x] Describe your PR's changes in the Release Notes section - [x] Create a Jira ticket for related docs-app-services work, if any ### Release Notes - **Swift SDK** - Sync Data/Manage Sync Sessions: Update the documentation for Upload and Download Progress Notifications, which have been updated for compatibility with Flexible Sync. ### Review Guidelines [REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md) --------- Co-authored-by: cbullinger <115956901+cbullinger@users.noreply.github.com>
1 parent 475864c commit ec69835

File tree

10 files changed

+137
-110
lines changed

10 files changed

+137
-110
lines changed

examples/ios/Examples/CustomUserData.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ - (void)testUpdateCustomUserData {
9292
RLMMongoClient *client = [user mongoClientWithServiceName:@"mongodb-atlas"];
9393
RLMMongoDatabase *database = [client databaseWithName:@"my_database"];
9494
RLMMongoCollection *collection = [database collectionWithName:@"users"];
95+
// :remove-start:
96+
[collection insertOneDocument:
97+
@{@"userId": [user identifier], @"favoriteColor": @"pink"}
98+
completion:^(id<RLMBSON> newObjectId, NSError *error) {
99+
if (error != nil) {
100+
NSLog(@"Failed to insert: %@", error);
101+
}
102+
NSLog(@"Inserted custom user data document with object ID: %@", newObjectId);
103+
// :remove-start:
104+
XCTAssertNotNil(newObjectId);
105+
// :remove-end:
106+
}];
107+
sleep(5);
108+
// :remove-end:
95109

96110
// Update the user's custom data document
97111
[collection updateOneDocumentWhere:@{@"userId": [user identifier]}

examples/ios/Examples/CustomUserData.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ class CustomUserData: XCTestCase {
9494
let client = user.mongoClient("mongodb-atlas")
9595
let database = client.database(named: "my_database")
9696
let collection = database.collection(withName: "users")
97+
// :remove-start:
98+
collection.insertOne([
99+
"userId": AnyBSON(user.id),
100+
"favoriteColor": "pink"
101+
]) { (result) in
102+
switch result {
103+
case .failure(let error):
104+
print("Failed to insert document: \(error.localizedDescription)")
105+
case .success(let newObjectId):
106+
print("Inserted custom user data document with object ID: \(newObjectId)")
107+
XCTAssertNotNil(newObjectId)
108+
}
109+
}
110+
sleep(5)
111+
// :remove-end:
97112
collection.updateOneDocument(
98113
filter: ["userId": AnyBSON(user.id)],
99114
update: ["favoriteColor": "cerulean"]

examples/ios/Examples/DeleteUsers.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,11 @@ class DeleteUsers: XCTestCase {
6767
XCTAssertEqual(app.allUsers.count, 0)
6868
}
6969
// :snippet-end:
70+
71+
override func setUp() async throws {
72+
for user in app.allUsers {
73+
try await user.value.delete()
74+
}
75+
XCTAssertEqual(app.allUsers.count, 0)
76+
}
7077
}

examples/ios/Examples/Sync.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ - (void)testCheckProgress {
143143
// :snippet-start: check-progress
144144
RLMSyncSession *syncSession = [syncedRealm syncSession];
145145
RLMProgressNotificationToken *token = [syncSession
146-
addProgressNotificationForDirection:RLMSyncProgressDirectionUpload
146+
addSyncProgressNotificationForDirection:RLMSyncProgressDirectionUpload
147147
mode:RLMSyncProgressModeForCurrentlyOutstandingWork
148-
block:^(NSUInteger transferredBytes, NSUInteger transferrableBytes) {
149-
NSLog(@"Uploaded %luB / %luB", (unsigned long)transferredBytes, transferrableBytes);
148+
block:^(RLMSyncProgress syncProgress) {
149+
NSLog(@"Uploaded %fB", (double)syncProgress.progressEstimate);
150150
// :remove-start:
151151
[expectation fulfill];
152152
// :remove-end:

examples/ios/Examples/Sync.swift

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,29 +185,77 @@ class Sync: AnonymouslyLoggedInTestCase {
185185
let expectation = XCTestExpectation(description: "it completes")
186186
expectation.assertForOverFulfill = false
187187

188-
// :snippet-start: check-progress
189188
let syncSession = syncedRealm.syncSession!
190189
let token = syncSession.addProgressNotification(
191190
for: .upload, mode: .forCurrentlyOutstandingWork) { (progress) in
192191

193-
let transferredBytes = progress.transferredBytes
194-
let transferrableBytes = progress.transferrableBytes
195-
let transferPercent = progress.fractionTransferred * 100
192+
let transferPercent = progress.progressEstimate * 100
196193

197-
print("Uploaded \(transferredBytes)B / \(transferrableBytes)B (\(transferPercent)%)")
198-
// :remove-start:
194+
print("Uploaded (\(transferPercent)%)")
199195
expectation.fulfill()
200-
// :remove-end:
201196
}
202197

203198
// Upload something
204199
try! syncedRealm.write {
205200
syncedRealm.add(SyncExamples_Task())
206201
}
207-
// :snippet-end:
208202
wait(for: [expectation], timeout: 10)
209203
}
210204

205+
@MainActor
206+
func testCheckProgressFlexibleSync() async {
207+
let app = App(id: APPID)
208+
let expectation = XCTestExpectation(description: "Progress notification is sent")
209+
210+
do {
211+
let user = try await app.login(credentials: Credentials.anonymous)
212+
var flexSyncConfig = user.flexibleSyncConfiguration()
213+
flexSyncConfig.objectTypes = [FlexibleSync_Task.self]
214+
do {
215+
let realm = try await Realm(configuration: flexSyncConfig)
216+
let subscriptions = realm.subscriptions
217+
try await subscriptions.update {
218+
subscriptions.append(QuerySubscription<FlexibleSync_Task>())
219+
}
220+
checkSyncProgress(realm: realm)
221+
} catch {
222+
print("Failed to open realm: \(error.localizedDescription)")
223+
// handle error
224+
}
225+
} catch {
226+
fatalError("Login failed: \(error.localizedDescription)")
227+
}
228+
229+
func checkSyncProgress(realm: Realm) {
230+
let todo = FlexibleSync_Task()
231+
todo.dueDate = (Date.now + TimeInterval(86400))
232+
todo.taskName = "This task should appear in the Flex Sync realm"
233+
todo.progressMinutes = 20
234+
todo.completed = false
235+
236+
// :snippet-start: check-progress-estimate
237+
let syncSession = realm.syncSession!
238+
let token = syncSession.addProgressNotification(
239+
for: .upload, mode: .forCurrentlyOutstandingWork) { (progress) in
240+
241+
let progressEstimate = progress.progressEstimate
242+
let transferPercent = progressEstimate * 100
243+
244+
print("Uploaded (\(transferPercent)%)")
245+
// :remove-start:
246+
// Verify that progress increases.
247+
XCTAssertGreaterThanOrEqual(progress.progressEstimate, progressEstimate)
248+
expectation.fulfill()
249+
// :remove-end:
250+
}
251+
// :snippet-end:
252+
try! realm.write {
253+
realm.add(todo)
254+
}
255+
}
256+
await fulfillment(of: [expectation], timeout: 10)
257+
}
258+
211259
func testSetClientLogLevelDeprecated() {
212260
// :snippet-start: set-log-level-deprecated
213261
// This code example shows how to set the log level

examples/ios/RealmExamples.xcodeproj/project.pbxproj

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
914601F726A86B9100BC91EA /* Sync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914601F526A86B9000BC91EA /* Sync.swift */; };
6464
914AC1BD28A3EAE00005E3C3 /* QuickStartFlexSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914AC1BC28A3EAE00005E3C3 /* QuickStartFlexSync.swift */; };
6565
914E8AD827F4C08100B8591D /* ClientReset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914E8AD727F4C08100B8591D /* ClientReset.swift */; };
66+
91508B792BE57F3F00817DBC /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 91508B782BE57F3F00817DBC /* RealmSwift */; };
6667
9157C1BC2AD059FF0059281A /* SyncTestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9157C1BB2AD059FF0059281A /* SyncTestUtils.swift */; };
6768
915B8EE529258B4300150F01 /* CreateObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 915B8EE429258B4300150F01 /* CreateObjects.swift */; };
6869
915B8EE629258B4300150F01 /* CreateObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 915B8EE429258B4300150F01 /* CreateObjects.swift */; };
@@ -84,21 +85,12 @@
8485
91713B1728AC3D8400519F9D /* SwiftUICatalogUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B1628AC3D8400519F9D /* SwiftUICatalogUITests.swift */; };
8586
91713B2528AC3DF300519F9D /* OpenRealm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B2428AC3DF300519F9D /* OpenRealm.swift */; };
8687
91713B2728AC3DF300519F9D /* OpenRealm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B2428AC3DF300519F9D /* OpenRealm.swift */; };
87-
91713B2928AC3E7A00519F9D /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 91713B2828AC3E7A00519F9D /* Realm */; };
88-
91713B2B28AC3E7A00519F9D /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 91713B2A28AC3E7A00519F9D /* RealmSwift */; };
89-
91713B2D28AC400400519F9D /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 91713B2C28AC400400519F9D /* Realm */; };
90-
91713B2F28AC400400519F9D /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 91713B2E28AC400400519F9D /* RealmSwift */; };
9188
91713B3128AC41B700519F9D /* Authenticate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3028AC41B700519F9D /* Authenticate.swift */; };
9289
91713B3328AC41B700519F9D /* Authenticate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3028AC41B700519F9D /* Authenticate.swift */; };
9390
91713B3528AD2B0E00519F9D /* PassObjectsToView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3428AD2B0E00519F9D /* PassObjectsToView.swift */; };
9491
91713B3728AD2B0E00519F9D /* PassObjectsToView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3428AD2B0E00519F9D /* PassObjectsToView.swift */; };
9592
91713B3928AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
9693
91713B3B28AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
97-
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; };
98-
9175294A28467FB700F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294928467FB700F8CB03 /* Realm */; };
99-
9175294C28467FB700F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294B28467FB700F8CB03 /* RealmSwift */; };
100-
917529522846803200F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 917529512846803200F8CB03 /* Realm */; };
101-
917529542846803200F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 917529532846803200F8CB03 /* RealmSwift */; };
10294
91787E5429E594C100296021 /* RealmActor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91787E5329E594C100296021 /* RealmActor.swift */; };
10395
917C6E662A8E638F00EC3079 /* SupportedTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 917C6E652A8E638F00EC3079 /* SupportedTypes.swift */; };
10496
917C6E682A8E63E900EC3079 /* SupportedTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 917C6E672A8E63E900EC3079 /* SupportedTypes.m */; };
@@ -126,7 +118,6 @@
126118
91E5C80128256C6D00AAA239 /* EventLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E5C80028256C6D00AAA239 /* EventLibrary.swift */; };
127119
91E608AD296E114500F84EA5 /* SyncedRealmCRUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E608AC296E114500F84EA5 /* SyncedRealmCRUD.swift */; };
128120
91F046992A29299A000B43B2 /* Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91F046982A29299A000B43B2 /* Logging.swift */; };
129-
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
130121
91FBD320279865080005C10C /* DeleteUsers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91FBD31F279865080005C10C /* DeleteUsers.swift */; };
131122
/* End PBXBuildFile section */
132123

@@ -154,7 +145,6 @@
154145
dstPath = "";
155146
dstSubfolderSpec = 10;
156147
files = (
157-
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */,
158148
);
159149
name = "Embed Frameworks";
160150
runOnlyForDeploymentPostprocessing = 0;
@@ -285,7 +275,7 @@
285275
files = (
286276
917CA79827ECADC200F9BDDC /* FacebookLogin in Frameworks */,
287277
9143E95327EB79BD0082A5D6 /* GoogleSignIn in Frameworks */,
288-
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */,
278+
91508B792BE57F3F00817DBC /* RealmSwift in Frameworks */,
289279
917CA79627ECADC200F9BDDC /* FacebookCore in Frameworks */,
290280
);
291281
runOnlyForDeploymentPostprocessing = 0;
@@ -294,35 +284,27 @@
294284
isa = PBXFrameworksBuildPhase;
295285
buildActionMask = 2147483647;
296286
files = (
297-
9175294C28467FB700F8CB03 /* RealmSwift in Frameworks */,
298-
9175294A28467FB700F8CB03 /* Realm in Frameworks */,
299287
);
300288
runOnlyForDeploymentPostprocessing = 0;
301289
};
302290
91713AF628AC3D8200519F9D /* Frameworks */ = {
303291
isa = PBXFrameworksBuildPhase;
304292
buildActionMask = 2147483647;
305293
files = (
306-
91713B2B28AC3E7A00519F9D /* RealmSwift in Frameworks */,
307-
91713B2928AC3E7A00519F9D /* Realm in Frameworks */,
308294
);
309295
runOnlyForDeploymentPostprocessing = 0;
310296
};
311297
91713B0F28AC3D8300519F9D /* Frameworks */ = {
312298
isa = PBXFrameworksBuildPhase;
313299
buildActionMask = 2147483647;
314300
files = (
315-
91713B2F28AC400400519F9D /* RealmSwift in Frameworks */,
316-
91713B2D28AC400400519F9D /* Realm in Frameworks */,
317301
);
318302
runOnlyForDeploymentPostprocessing = 0;
319303
};
320304
91C687FA274D8AFE001A5DBE /* Frameworks */ = {
321305
isa = PBXFrameworksBuildPhase;
322306
buildActionMask = 2147483647;
323307
files = (
324-
917529542846803200F8CB03 /* RealmSwift in Frameworks */,
325-
917529522846803200F8CB03 /* Realm in Frameworks */,
326308
);
327309
runOnlyForDeploymentPostprocessing = 0;
328310
};
@@ -580,7 +562,7 @@
580562
9143E95227EB79BD0082A5D6 /* GoogleSignIn */,
581563
917CA79527ECADC200F9BDDC /* FacebookCore */,
582564
917CA79727ECADC200F9BDDC /* FacebookLogin */,
583-
9175294728467FA000F8CB03 /* RealmSwift */,
565+
91508B782BE57F3F00817DBC /* RealmSwift */,
584566
);
585567
productName = RealmExampleTests;
586568
productReference = 4896EE4C2510514B00D1FABF /* RealmExamples.xctest */;
@@ -600,8 +582,6 @@
600582
);
601583
name = SwiftUIFlexSyncExample;
602584
packageProductDependencies = (
603-
9175294928467FB700F8CB03 /* Realm */,
604-
9175294B28467FB700F8CB03 /* RealmSwift */,
605585
);
606586
productName = SwiftUIFlexSyncExample;
607587
productReference = 912ACA7828415292006CDDD8 /* SwiftUIFlexSyncExample.app */;
@@ -621,8 +601,6 @@
621601
);
622602
name = SwiftUICatalog;
623603
packageProductDependencies = (
624-
91713B2828AC3E7A00519F9D /* Realm */,
625-
91713B2A28AC3E7A00519F9D /* RealmSwift */,
626604
);
627605
productName = SwiftUICatalog;
628606
productReference = 91713AF928AC3D8200519F9D /* SwiftUICatalog.app */;
@@ -643,8 +621,6 @@
643621
);
644622
name = SwiftUICatalogUITests;
645623
packageProductDependencies = (
646-
91713B2C28AC400400519F9D /* Realm */,
647-
91713B2E28AC400400519F9D /* RealmSwift */,
648624
);
649625
productName = SwiftUICatalogUITests;
650626
productReference = 91713B1228AC3D8300519F9D /* SwiftUICatalogUITests.xctest */;
@@ -664,8 +640,6 @@
664640
);
665641
name = SwiftUIExamples;
666642
packageProductDependencies = (
667-
917529512846803200F8CB03 /* Realm */,
668-
917529532846803200F8CB03 /* RealmSwift */,
669643
);
670644
productName = QuickStartSwiftUI;
671645
productReference = 91C68804274D8AFE001A5DBE /* SwiftUIExamples.app */;
@@ -713,7 +687,7 @@
713687
packageReferences = (
714688
9143E95127EB79BD0082A5D6 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */,
715689
917CA79427ECADC200F9BDDC /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */,
716-
9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */,
690+
91508B752BE57EFA00817DBC /* XCRemoteSwiftPackageReference "realm-swift" */,
717691
);
718692
productRefGroup = 48DBFAD725101C3100391E2B /* Products */;
719693
projectDirPath = "";
@@ -1485,12 +1459,12 @@
14851459
version = 6.1.0;
14861460
};
14871461
};
1488-
9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */ = {
1462+
91508B752BE57EFA00817DBC /* XCRemoteSwiftPackageReference "realm-swift" */ = {
14891463
isa = XCRemoteSwiftPackageReference;
14901464
repositoryURL = "https://github.com/realm/realm-swift.git";
14911465
requirement = {
14921466
kind = exactVersion;
1493-
version = 10.49.3;
1467+
version = 10.50.0;
14941468
};
14951469
};
14961470
917CA79427ECADC200F9BDDC /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */ = {
@@ -1509,49 +1483,9 @@
15091483
package = 9143E95127EB79BD0082A5D6 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */;
15101484
productName = GoogleSignIn;
15111485
};
1512-
91713B2828AC3E7A00519F9D /* Realm */ = {
1486+
91508B782BE57F3F00817DBC /* RealmSwift */ = {
15131487
isa = XCSwiftPackageProductDependency;
1514-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1515-
productName = Realm;
1516-
};
1517-
91713B2A28AC3E7A00519F9D /* RealmSwift */ = {
1518-
isa = XCSwiftPackageProductDependency;
1519-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1520-
productName = RealmSwift;
1521-
};
1522-
91713B2C28AC400400519F9D /* Realm */ = {
1523-
isa = XCSwiftPackageProductDependency;
1524-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1525-
productName = Realm;
1526-
};
1527-
91713B2E28AC400400519F9D /* RealmSwift */ = {
1528-
isa = XCSwiftPackageProductDependency;
1529-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1530-
productName = RealmSwift;
1531-
};
1532-
9175294728467FA000F8CB03 /* RealmSwift */ = {
1533-
isa = XCSwiftPackageProductDependency;
1534-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1535-
productName = RealmSwift;
1536-
};
1537-
9175294928467FB700F8CB03 /* Realm */ = {
1538-
isa = XCSwiftPackageProductDependency;
1539-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1540-
productName = Realm;
1541-
};
1542-
9175294B28467FB700F8CB03 /* RealmSwift */ = {
1543-
isa = XCSwiftPackageProductDependency;
1544-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1545-
productName = RealmSwift;
1546-
};
1547-
917529512846803200F8CB03 /* Realm */ = {
1548-
isa = XCSwiftPackageProductDependency;
1549-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1550-
productName = Realm;
1551-
};
1552-
917529532846803200F8CB03 /* RealmSwift */ = {
1553-
isa = XCSwiftPackageProductDependency;
1554-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1488+
package = 91508B752BE57EFA00817DBC /* XCRemoteSwiftPackageReference "realm-swift" */;
15551489
productName = RealmSwift;
15561490
};
15571491
917CA79527ECADC200F9BDDC /* FacebookCore */ = {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let syncSession = realm.syncSession!
2+
let token = syncSession.addProgressNotification(
3+
for: .upload, mode: .forCurrentlyOutstandingWork) { (progress) in
4+
5+
let progressEstimate = progress.progressEstimate
6+
let transferPercent = progressEstimate * 100
7+
8+
print("Uploaded (\(transferPercent)%)")
9+
}

source/examples/generated/code/start/Sync.snippet.check-progress.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
RLMSyncSession *syncSession = [syncedRealm syncSession];
22
RLMProgressNotificationToken *token = [syncSession
3-
addProgressNotificationForDirection:RLMSyncProgressDirectionUpload
3+
addSyncProgressNotificationForDirection:RLMSyncProgressDirectionUpload
44
mode:RLMSyncProgressModeForCurrentlyOutstandingWork
5-
block:^(NSUInteger transferredBytes, NSUInteger transferrableBytes) {
6-
NSLog(@"Uploaded %luB / %luB", (unsigned long)transferredBytes, transferrableBytes);
5+
block:^(RLMSyncProgress syncProgress) {
6+
NSLog(@"Uploaded %fB", (double)syncProgress.progressEstimate);
77
}];
88

99
// Upload something

0 commit comments

Comments
 (0)