mitter.io
  • Welcome
  • Migrating from cloud to on-prem
  • Get mitter.io
    • Custom configuration
  • Getting started
    • Build Your First Android App
      • Setup
      • Authenticate a User
      • Start a Basic Chat
      • Selective Deliveries
      • Custom Payloads
    • Build Your First iOS App
      • Overview
      • Installation
      • Basic Setup
      • Receive Push Messages
      • Storyboard
      • Channel List
      • Channel Window
    • Build Your First Web App
      • Setting Up Your App
      • Start a Basic Chat
      • Selective Deliveries
    • Build Your First React Native app
  • Platform Reference
    • Introduction
    • Concepts
    • Authorization and Access
    • Calling the APIs
    • Users
    • Channels
      • Channel Streams and Typing Indicators
    • Messages
    • Delivery Endpoints (Push Notifications)
    • Federated Authentication
    • Basic Permissions and Privileges
    • ACLs and Advanced Permission Model
    • Metadata
  • SDKs
    • Android
      • Getting Started
      • Set up FCM
      • Presence and Timeline Events
      • Profiles, Pagination and Locators
      • Using the UI Framework
    • iOS
      • Installation
      • Basic Setup
      • Get the current user details
      • Create a Channel
      • Messaging
      • Push Messages
    • Javascript
      • Using the UI framework (web only)
      • For react-native
      • For node.js
      • TSDocs / JSDocs
      • For Typescript Users
    • Java (Backend)
Powered by GitBook
On this page
  1. SDKs
  2. iOS

Get the current user details

Now, go to your main ViewController which is the ViewController.swift file under your project.

Inside the viewDidLoad() function, get a reference to your AppDelegate instance by adding the following line:

let appDelegate = UIApplication.shared.delegate as! AppDelegate

Now, you can easily make a call to Mitter and see the currently authenticated user details by calling the getCurrentUsers() function on the Mitter.Users object.

This can be done like this:

                appDelegate.mitter.users.getCurrentUser {
                    result in
                    switch result {
                    case .success(let user):
                        print("Current User is: \(user)")
                    case .error:
                        print("Unable to get user!")
                    }
                }

Now, press ⌘R to run your project in any iPhone simulator.

If everything’s setup according to the previous steps, you should be able to see the currently authenticated user details printed to your console log inside Xcode.

PreviousBasic SetupNextCreate a Channel

Last updated 6 years ago