You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: firestore-counter/POSTINSTALL.md
+53-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,10 @@ match /databases/{database}/documents/pages/{page} {
20
20
```
21
21
22
22
23
-
#### Specify a document path and increment value in your web app
23
+
#### Client samples for incrementing counter and retrieving its value
24
+
25
+
##### Web Client
26
+
24
27
25
28
1. Download and copy the [compiled client sample](https://github.com/firebase/extensions/blob/master/firestore-counter/clients/web/dist/sharded-counter.js) into your application project.
26
29
@@ -60,6 +63,55 @@ match /databases/{database}/documents/pages/{page} {
60
63
</html>
61
64
```
62
65
66
+
##### iOS Client
67
+
68
+
1. Ensure your Swift app already has Firebase [initialized](https://firebase.google.com/docs/ios/setup).
69
+
2. Copy and paste the sample [code](https://github.com/firebase/extensions/blob/next/firestore-counter/clients/ios/Sources/FirestoreCounter/FirestoreCounter.swift) and create this file `FirestoreShardedCounter.swift` in the relevant directory you wish to use the `FirestoreShardedCounter` instance.
70
+
71
+
```swift
72
+
importUIKit
73
+
importFirestoreCounter
74
+
importFirebaseFirestore
75
+
76
+
classViewController: UIViewController {
77
+
// somewhere in your app code initialize Firestore instance
78
+
var db = Firestore.firestore()
79
+
// create reference to the collection and the document you wish to use
80
+
var doc = db.collection("pages").document("hello-world")
81
+
// initialize FirestoreShardedCounter with the document and the property which will hold the counter value
82
+
var controller =FirestoreShardCounter(docRef: doc, field: "visits")
0 commit comments