• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Objective-C
  • Created over 12 years ago
  • Updated almost 7 years ago

Reviews

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

Repository Details

Unique Identifier Is Dead, Long Live Unique Identifier

As of iOS 5, Apple has deprecated the device unique identifier api and hasn’t provided a friendly Obj-C replacement, instead recommending CFUUIDCreate and NSUserDefaults.

CFUUIDCreate isn’t very complicated and neither is NSUserDefaults, but this solution fails in a few different ways:

  • It’s not a quick one-shot call to get the UUID; you have to write your own wrapper to make it friendly
  • It doesn’t persist; deleting the app blows away the UUID
  • There’s no way to share it between apps

The answer to these issues is to create a class that acts as the wrapper and improves on the persistence and sharing options using Keychain.

Quick Keychain primer:

On iOS each apps gets its own keychain where it can store sensitive data that only that app can access, with some very particular exceptions. This keychain is persisted across installations and, if the user encrypts their backups, across restores. A full restore and setup as a new device or restore from unencrypted backup wipes the keychain.

This gives us a place to store an app (or app suite) specific UUID that will last as long as a given user continues using that device, but that will change if they do a full restore. That’s a nice level of fidelity that suits most legitimate tracking needs, like identifying that a device is already known to a web service tracking active devices. A given device won’t have two UUIDs simultaneously and for most users won’t change until they get a new device.

Another useful feature of Keychain is support for access groups, which allow iOS applications from the same provider to opt in to sharing a common keychain. The UUID can be stored in a keychain that all the apps can access, thus allowing us to know that a given set of installations all represent a single device.

“So this all seems interesting, but where’s the code?” – Nerds Still Reading This

 @interface BPXLUUIDHandler : NSObject
 /*
  * Retrieve UUID from keychain, if one does not exist, generate one and store it in the keychain.
  * UUIDs stored in the keychain will perisist across application installs
  * but not across device restores.
  */
 + (NSString *)UUID;
 /*
  * Remove stored UUID from keychain
  /
 + (void)reset;
 /*
  * Getter/setter for access group used for reading/writing from keychain.
  * Useful for shared keychain access across applications with the
  * same bundle seed (requires properly configured provisioning and entitlements)
  */
 + (NSString *)accessGroup;
 + (void)setAccessGroup:(NSString *)accessGroup;
 @end

BPXLUUIDHandler is a class we created to encapsulate all the handling of getting/storing the new UUID and added support for access groups since some of our clients have application suites.

It supports ARC and non ARC configurations and tucks away all the keychain interaction so that we don’t have to keep writing the same blob of keychain queries again and again.

Use and enjoy and provide feedback.

—Unique Identifier Is Dead, Long Live Unique Identifier

How to

  • Import BPXLUUIDHandler.h
  • Retrieve the UUID with [BPXLUUIDHandler UUID]
  • Done!

Non-ARC projects are support out of the box.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

More Repositories

1

IAPKit

A simple approach to Apple In App Purchases (IAP) that handles the presentation of products, purchasing, receipt validation, and timed free trials.
C
500
star
2

react-component-hierarchy

A CLI app for visualizing how React components are structured in a project.
JavaScript
119
star
3

StatusBarLayer

A Framer module for generating accurate, customizable status bars for iOS app prototypes.
CoffeeScript
52
star
4

ControlPanelLayer

A Framer module for creating a developer panel to control aspects of the prototype from within the prototype.
CoffeeScript
34
star
5

RemoteLayer

A Framer module to generate an interactive Apple TV remote for tvOS app prototypes.
CoffeeScript
30
star
6

redux-generators

CLI tool for quickly and easily scaffolding Redux applications
JavaScript
29
star
7

FocusEngine

A Framer module for simulating the grid focus behavior found on Apple TV and Roku.
CoffeeScript
23
star
8

GradientHelper

A Framer module for applying gradients to layers and animating them.
CoffeeScript
21
star
9

MapboxLayer

A Framer module for creating powerful Mapbox maps in your prototypes.
CoffeeScript
20
star
10

CarouselComponent

A Framer module for creating a scrolling carousel of items in various configurations.
CoffeeScript
18
star
11

NavbarComponent

A Framer module for generating an iOS-style navigation bar.
CoffeeScript
16
star
12

redux-handbook

Black Pixel Redux Handbook
CSS
12
star
13

AutoDC

Automated data-centric processing
Python
10
star
14

BreakOut

BreakOut Demo for the iPad featured at the Seattle Voices That Matter Conference
C++
7
star
15

firefly

Shell
7
star
16

terraform-aws-s3-static-site

HCL
6
star
17

terraform-kubernetes-flux2-bootstrap

Boostrap a flux deployment on EKS
HCL
5
star
18

usoniancss

A CSS toolkit for building scalable, performant UI.
CSS
4
star
19

hue-gallery

A client-side web app that extracts an image’s color palette and sends it to the Philips Hue API. Featured in Net Magazine's December 2016 issue.
JavaScript
4
star
20

framer-module-boilerplate

Framer Module Boilerplate
CoffeeScript
3
star
21

payload-command-console

C++
3
star
22

hyperdrive

Python
2
star
23

redux-todomvc

Black Pixel's Redux Todomvc example. Architecture based on http://bpxl-labs.github.io/redux-handbook/
JavaScript
2
star
24

DebugInjectorSample

Securely add debug-only functionality to Android apps and test locale changes in debug builds.
Java
1
star
25

metal-lab

Getting the basic pipeline of metal figured out
Swift
1
star
26

bpxl-animation-samples

Examples illustrating iOS 10’s UIPropertyViewAnimator API.
Swift
1
star