Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistent storage on Apple watch

I am looking for a way to store something on the Apple watch app that I can read later on enabling me to identify it uniquely.

I don't see any API at the moment that would let me do this. The closest I have got is to save an image in cache but since its just a cache, its not reliable.

My goal is to uniquely identify an Apple Watch.

Any pointers would be much appreciated.

like image 572
Venkat Avatar asked May 21 '15 08:05

Venkat


2 Answers

You can save information to be accessible from both watch and iPhone in NSUserDefaults and App Groups like this:

let defaults = NSUserDefaults(suiteName: "group.com.your-bundle-id.app-group-name")

where "group.com.your-bundle-id.app-group-name" is your app group identifier.

For more details about NSUserDefaults and other ways to share data between Watch and iPhone see Architecting Your App for the Apple Watch

like image 64
Dima Cheverda Avatar answered Sep 20 '22 11:09

Dima Cheverda


User App Groups OR NSUserDefaults to share data between your iOS apps.

Easily share small amounts of data between your iOS app and your WatchKit extension with App Groups and NSUserDefaults. For access to other resources, such as a Core Data store, use a shared container between your iOS app and your WatchKit extension to simplify data access and provide up to date information.

like image 23
Nilesh Patel Avatar answered Sep 21 '22 11:09

Nilesh Patel