• Stars
    star
    1,574
  • Rank 28,595 (Top 0.6 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ฑ ๐Ÿ†” iOS UUID / Universally Unique Identifiers library as alternative to UDID and identifierForVendor.

FCUUID Pod version Pod platforms Pod license

iOS UUID library as alternative to the old good UDID and identifierForVendor. This library provides the simplest API to obtain universally unique identifiers with different levels of persistence.

It's possible to retrieve the UUIDs created for all devices of the same user, in this way with a little bit of server-side help it's possible manage guest accounts across multiple devices easily.

Requirements & dependencies

  • iOS >= 5.0
  • ARC enabled
  • Key-value storage enabled (target / Capabilities / iCloud / Key-value storage)
  • Security.framework
  • UICKeyChainStore
  • (optional) - Key-value storage enabled -> Target / Capabilities / iCloud / Key-value storage enabled if you want to share uuidsOfUserDevices values across multiple devices using the same iCloud account.
  • (optional) - KeyChain sharing enabled (entitlements and provisioning profile) if you need to share the same uuidForDevice / uuidsOfUserDevices values across multiple apps with the same bundle seed.

Installation

CocoaPods:

pod 'FCUUID'

Swift Package Manager:

  1. File > Swift Packages > Add Package Dependency
  2. Add https://github.com/fabiocaccamo/FCUUID
  3. Select "Up to Next Major" with "1.0.0"

Carthage:

github "fabiocaccamo/FCUUID"

Manual install:

Optional setup:

It is recommended to do the setup in applicationDidFinishLaunchingWithOptions method.

  • Add an observer to the FCUUIDsOfUserDevicesDidChangeNotification to be notified about uuids of user devices changes.
  • If necessary, migrate from a previously used UUID or UDID using one of the migrations methods listed in the API section (it's recommended to do migration before calling uuidForDevice or uuidsForUserDevices methods). Keep in mind that migration works only if the existing value is a valid uuid and uuidForDevice has not been created yet.
  • Call any class method to enforce iCloud sync.

API

Get different UUIDs (each one with its own persistency level)

//changes each time (no persistent)
+(NSString *)uuid;

//changes each time (no persistent), but allows to keep in memory more temporary uuids
+(NSString *)uuidForKey:(id<NSCopying>)key;

//changes each time the app gets launched (persistent to session)
+(NSString *)uuidForSession;

//changes each time the app gets installed (persistent to installation)
+(NSString *)uuidForInstallation;

//changes each time all the apps of the same vendor are uninstalled (this works exactly as identifierForVendor)
+(NSString *)uuidForVendor;

//changes only on system reset, this is the best replacement to the good old udid (persistent to device)
+(NSString *)uuidForDevice;
//or
#import "UIDevice+FCUUID.h"
[[UIDevice currentDevice] uuid];

Get the list of UUIDs of user devices

//returns the list of all uuidForDevice of the same user, in this way it's possible manage guest accounts across multiple devices easily
+(NSArray *)uuidsOfUserDevices;

Migrate from a previously stored UUID / UDID Before migrating an existing value it's recommended to debug it by simply passing commitMigration:NO and logging the returned value. When you will be ready for committing the migration, use commitMigration:YES. After the migration, any future call to uuidForDevice will return the migrated value.

//these methods search for an existing UUID / UDID stored in the KeyChain or in UserDefaults for the given key / service / access-group
+(NSString *)uuidForDeviceMigratingValue:(NSString *)value commitMigration:(BOOL)commitMigration;
+(NSString *)uuidForDeviceMigratingValueForKey:(NSString *)key commitMigration:(BOOL)commitMigration;
+(NSString *)uuidForDeviceMigratingValueForKey:(NSString *)key service:(NSString *)service commitMigration:(BOOL)commitMigration;
+(NSString *)uuidForDeviceMigratingValueForKey:(NSString *)key service:(NSString *)service accessGroup:(NSString *)accessGroup commitMigration:(BOOL)commitMigration;

Check if value is a valid UUID

+(BOOL)uuidValueIsValid:(NSString *)uuidValue;

Persistence

  • โˆš yes
  • - no
  • * read notes below
PERSISTS App memory App relaunch Reset Advertising Identifier App reinstall System reboot System upgrade System reset
uuid - - - - - - -
uuidForKey:key โˆš - - - - - -
uuidForSession โˆš - - - - - -
uuidForInstallation โˆš โˆš โˆš - โˆš - -
uuidForVendor โˆš โˆš - โˆš* โˆš - -
uuidForDevice โˆš โˆš โˆš โˆš โˆš โˆš โˆš**

*(persists only if the user have not uninstalled all apps of the same vendor)

**(persists only if the user restores a device backup which includes also keychain's data)

FAQ

How can I share the device uuid between two apps?

You must have KeyChain sharing enabled (entitlements and provisioning profile) and your apps identifiers must have the same bundle seed.

What happens if I call uuidForDevice on 2 different devices using same iCloud account and iCloud Keychain?

You will obtain 2 different uuid(s), and if you call uuidsOfUserDevices you will obtain a list containing the uuids of both devices.

When I reboot / upgrade / reset my device system, will device uuid change?

Please check the persistence table above.

Support development

Donate

License

Released under MIT License.

More Repositories

1

django-admin-interface

๐Ÿฆธ โšก django's default admin interface with superpowers - customizable themes, popup windows replaced by modals and many other features.
CSS
1,546
star
2

python-benedict

๐Ÿ“˜ dict subclass with keylist/keypath support, built-in I/O operations (base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml), s3 support and many utilities.
Python
1,111
star
3

FCFileManager

๐Ÿ“ฑ ๐Ÿ“‚ iOS file manager on top of NSFileManager for simplifying files management.
Objective-C
899
star
4

django-colorfield

๐ŸŽจ color field for django models with a nice color-picker in the admin.
Python
519
star
5

django-treenode

๐ŸŒณ probably the best abstract model/admin for your tree based stuff.
Python
481
star
6

django-maintenance-mode

๐Ÿšง ๐Ÿ› ๏ธ shows a 503 error page when maintenance-mode is on.
Python
408
star
7

django-extra-settings

โš™๏ธ config and manage typed extra settings using just the django admin.
Python
359
star
8

FCCurrentLocationGeocoder

๐Ÿ“ฑ ๐Ÿ“ iOS geocoder for forward / reverse geocode user's current location using a block-based syntax.
Objective-C
262
star
9

python-fsutil

๐Ÿ’ป ๐Ÿ”ง high-level file-system operations for lazy devs.
Python
147
star
10

FCIPAddressGeocoder

๐Ÿ“ฑ ๐ŸŒ iOS geocoder for geocode device IP Address location using GeoIP service(s) and a block-based syntax.
Objective-C
114
star
11

django-freeze

๐ŸงŠ convert your dynamic django site to a static one with one line of code.
Python
89
star
12

python-codicefiscale

๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ’ณ italian fiscal codes encoding, decoding and validation - codifica, decodifica e validazione del Codice Fiscale italiano.
Python
62
star
13

django-redirects

โ†ช๏ธ โœ… redirects as they should be, with full control.
Python
55
star
14

python-fontbro

๐Ÿงข friendly font operations on top of fontTools.
Python
41
star
15

utils.js

๐Ÿ‘ท ๐Ÿ”ง zero dependencies vanilla JavaScript utils.
JavaScript
18
star
16

create-matrix-action

๐Ÿงช ๐Ÿ’ฅ GitHub action that creates a non-square matrix parsing a readable config.
Python
9
star
17

layers.css

๐Ÿ“‘ pure (s)css independent stacked layers, no js at all.
CSS
8
star
18

wall.css

๐Ÿงฑ pure (s)css block-grid implementation with extra features.
SCSS
8
star
19

FCMapsApp

๐Ÿ“ฑ ๐Ÿ—บ๏ธ iOS utility for launching external maps applications (Apple Maps, Google Maps, Waze, Yandex Maps), showing locations and getting directions.
Objective-C
7
star
20

FCUtils

๐Ÿ“ฑ ๐Ÿ”ง iOS utilities collection.
Objective-C
6
star
21

python-imageutil

๐ŸŽฉ ๐Ÿช„ high-level image operations, with a bit of magic. ๐Ÿฐ
Python
5
star
22

xhrm.js

JavaScript XMLHttpRequest manager built on top of jQuery $.ajax.
JavaScript
2
star
23

tabbo.js

๐Ÿซ โŒจ๏ธ enhanced keyboard tabbing usability on any website / webapp with one line of code.
JavaScript
1
star