Working with Auth0 User and App Metadata in iOS Apps
Tags: ios, mobile, programming
Published: 2022-09-01 15:15:58

> Original post written by [Joey deVilla](https://auth0.com/blog/authors/joey-devilla/) for Auth0 blog.

### Learn how to use user and app metadata in Auth0 user profiles to store additional information about your users.

### <br>

After learning how to add authentication to your [UIKit-](https://auth0.com/blog/get-started-ios-authentication-swift-uikit/) or [SwiftUI-](https://auth0.com/blog/get-started-ios-authentication-swift-swiftui-part-1-login-logout/)based iOS apps, you might want to store additional information about your users. You can do this by accessing the **_metadata_** in Auth0’s user profiles, which you’ll learn how to do in this tutorial.

> If you’re not familiar with integrating Auth0 authentication with iOS apps, we strongly recommend that you first go through the exercises in [_Get Started with iOS Authentication using Swift and UIKit_](https://auth0.com/blog/get-started-ios-authentication-swift-uikit/) or [_Get Started with iOS Authentication using SwiftUI_](https://auth0.com/blog/get-started-ios-authentication-swift-swiftui-part-1-login-logout/).

Look for the 🛠 emoji if you’d like to skim through the content while focusing on the build and execution steps. Harness the power of control-F/command-F to build the app in this tutorial quickly!


## User Metadata and App Metadata

Auth0’s user profiles store basic information about each user: a unique identifier, the names they use, their contact details, and other identifying information such as their picture. These are useful to know during the authentication process, but you may often need other information as the user logs in, such as:

- The user’s status: Is the user using the app on a trial basis, or are they a paying customer? Does the user have access to the app’s basic features, or did they purchase the deluxe package with all the features?
- User preferences, such as a preferred color scheme, light mode vs. dark mode, font size, and so on.
- Flags that track actions that the user has taken. Has the user accepted the app’s terms and conditions? Have they completed the tutorial?
- Other information about the user’s account: Is it time to show the user an alert, announcement, or notice? Is there an available upgrade for the app?

Auth0’s user profiles can store this kind of information as **metadata**, which your app can access once the user has logged in. This is information that your app could keep in its storage system, but Auth0’s user profile metadata has the advantage of being available immediately after and during the login process.

One particular advantage that metadata has is that it’s stored with the user’s account rather than on the device. If the user switches from the mobile version of an app to its web version (or vice versa), their metadata-based settings and preferences will be the same in both versions.

<a href="https://auth0.com/actions"><img src="https://images.ctfassets.net/kbkgmx9upatd/1qmEPBTvtLQkbpIvg9z6sr/c46aaf3cc70a442d3499ee9b54e306c9/action-icon.svg" align="right" style="padding:0 0 0 10px"></a>Better still, Auth0’s [Actions](https://auth0.com/actions) — custom Node-based code that you can add to your tenant — can use your users’ metadata to perform tasks during many Auth0 workflows, such as when they log in, register for an account, or change their password.

To give you a better idea of what your apps can do with metadata, this app you’ll make in this article’s exercise uses two kinds of metadata:

- **User metadata,** which the user *can* see and update. It’s meant to store user preferences, settings, and other data that _do not_ impact the core functionality available to the user.
- **App metadata,** which the user *cannot* see but is accessible by the application. It’s for storing settings and other data that _do_ impact the application’s core functionality, such as tracking user activity and determining what features or activities should be available to the user.

In this tutorial, you’ll add metadata features to a “starter” app that lets a user view and update their user metadata and displays an announcement if the user’s app metadata contains a specific value.

[Read more...](https://auth0.com/blog/working-auth0-user-app-metadata-ios-apps/?utm_source=devto&utm_medium=sc&utm_campaign=devto)