From bf8a97155de5c8e767d2d2494e9ba6b1fab0de93 Mon Sep 17 00:00:00 2001 From: Cody Kerns <44073103+codykerns@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:24:11 -0500 Subject: [PATCH] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 0692bcf..eb9f3e4 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ StableID.identify(id: ) To receive updates when a user ID changes (for example from detecting a change from another iCloud device), configure a delegate: ```swift +// call after configuring StableID StableID.set(delegate: MyClass()) class MyClass: StableIDDelegate { @@ -67,6 +68,27 @@ class MyClass: StableIDDelegate { } ``` +### Custom ID Generators + +By default, StableID uses a standard `IDGenerator` that generates simple UUIDs. + +If you want any generated identifiers to follow a certain pattern, you can implement a custom ID generator by conforming to `IDGenerator` and implementing `generateID()`: + +```swift +struct MyCustomIDGenerator: IDGenerator { + func generateID() -> String { + // do something custom + return myGeneratedID + } +} +``` + +Then pass the generator as part of the `configure` method: + +```swift +StableID.configure(idGenerator: MyCustomIDGenerator()) +``` + ## License MIT