---
updatedAt: 2026-05-21T09:44:25.000Z
agentTools:
  projectIndex: https://docs.damoov.com/llms.txt
---

# Framework for iOS app

Configure the simplest way to work with User login and auth

## LoginAuth Framework for iOS

[block:embed]
{
  "html": false,
  "url": "https://github.com/Mobile-Telematics/LoginAuthFramework-iOS",
  "title": "GitHub - Mobile-Telematics/LoginAuthFramework-iOS: Telematics SDK Login and authentication framework for iOS apps",
  "favicon": "https://github.com/favicon.ico",
  "image": "https://opengraph.githubassets.com/6285da92c288bdbc6bd2a62cf8d83da0fe7179cd4c6f93fa1d2327f7d01bfafd/Mobile-Telematics/LoginAuthFramework-iOS"
}
[/block]

### Description

This library is created by DATA MOTION PTE. LTD. and allows you to integrate with our UserService API in a few steps.

LoginAuth Framework main functions:

1. Register `deviceToken` for each new Telematics SDK user.
2. Refresh the `accessToken (JWT)` when it is expired.
3. Authorize existing SDK user
4. Get authorized user profile info
5. Update authorized user profile info

### Credentials

Before you start using the framework, make sure you registered a company account in [DataHub](https://app.damoov.com/) and obtained `InstanceID` and`InstanceKEY`. If you are new, please refer to the [documentation](https://docs.telematicssdk.com/docs/setting-up-the-company-account) and register your company account in DataHub. [Sing Up](https://app.damoov.com/user/registration)

### LoginAuth Framework setup

Here you can find a short video guide, how to add LoginAuth Framework to your iOS app:

[block:embed]
{
  "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FrlqSjvLa_Nk%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrlqSjvLa_Nk&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FrlqSjvLa_Nk%2Fhqdefault.jpg&key=f2aa6fc3595946d0afc3d76cbbd25dc3&type=text%2Fhtml&schema=youtube\" width=\"640\" height=\"480\" scrolling=\"no\" title=\"YouTube embed\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen=\"true\"></iframe>",
  "url": "https://www.youtube.com/watch?v=rlqSjvLa_Nk&feature=youtu.be",
  "title": "iOS LoginAuth Framework Integration Guide",
  "favicon": "https://www.youtube.com/s/desktop/aa517dff/img/favicon.ico",
  "image": "https://i.ytimg.com/vi/rlqSjvLa_Nk/hqdefault.jpg"
}
[/block]

#### To integrate the framework, you need to perform a few simple steps:

Step 1: Download the `LoginAuth.xcframework` library from this repository.

Step 2: Copy `LoginAuth.xcframework` to your iOS project folder where the rest of your project files are located.

Step 3: Open your project in xCode.

Step 4: Go to the first General tab of your project, select your Target.

Step 5: Scroll down to the "Frameworks, Libraries and Embeddeed Content" section.

Step 6: Drag\&Drop`LoginAuth.xcframework` from Finder project folder to this section, OR click the "Plus" button below, and select "Add Other" and manually specify the path to the `LoginAuth.xcframework` location.

![](https://github.com/Mobile-Telematics/LoginAuthFramework-iOS/raw/master/images/al.png)

Step 7: Add in header AppDelegate.h (or any file need for you) of your project this line `#import <LoginAuth/LoginAuth.h>`

Step 8: Enjoy!

### Basic concepts

`deviceToken` - is the main individual SDK user identifier for your app. This identifier is used as a key across all our services.

`accessToken` - or JSON Web Token (JWT) is the main UserService API key, that allows you to get user individual statistics and user scoring by UserService APIs calls.

`refreshToken` - is a secret key that allows you to refresh the `accessToken` when it expires.

### Methods

#### Create DeviceToken

Each SDK user has to have a `DeviceToken` and be associated with the app users. To create `DeviceToken` please use the method below. To complete a call, you are required to provide `instanceId` & `instanceKey`. If you still have questions on how to obtain the credentials, please refer to the [documentation](https://docs.damoov.com/docs/datahub#user-service-credentials)

[block:code]
{
  "codes": [
    {
      "code": "[[LoginAuthCore sharedManager] createDeviceTokenForUserWithInstanceId:@\"instanceId\"\n                                                          instanceKey:@\"instanceKey\"\n                                                               result:^(NSString *deviceToken, NSString *jwToken, NSString *refreshToken) {\n    NSLog(@\"LoginAuthResponce deviceToken %@\", deviceToken);\n    NSLog(@\"LoginAuthResponce jwToken %@\", jwToken);\n    NSLog(@\"LoginAuthResponce refreshToken %@\", refreshToken);\n}];",
      "language": "objectivec"
    },
    {
      "code": "LoginAuthCore.sharedManager()?.createDeviceTokenForUser(withInstanceId: \"instanceId\",\n                                                           instanceKey: \"instanceKey\",\n                                                                result: { (deviceToken, jwToken, refreshToken) in\n    print(\"Success Create User\")\n})",
      "language": "swift"
    }
  ]
}
[/block]

Once user is registered, you will receive the user credentails. make sure you pass the `Devicetoken` to your server and store it against a user profile, then pass it to your App - this is the main user detials that you will use for our services.

#### Refresh JWT

Each `JWTtoken` has a limmited lifetime and in a certain period of time it is expired. As a result, when you call our API using invalid `JWTtoken` you will receive an Error `Unauthorized 401`.
**Error 401** indicates that the user's `JWTtoken` has been expired. If so, as the first step, you have to update the `JWToken`.

To update the `JWTtoken`, you are required to provide the latest `JWTtoken` & `refreshToken` to the method below.

[block:code]
{
  "codes": [
    {
      "code": "[[LoginAuthCore sharedManager] refreshJWTokenForUserWith:@\"jwToken\"\n                                            refreshToken:@\"refreshToken\"\n                                                  result:^(NSString *newJWToken, NSString *newRefreshToken) {\n\n    NSLog(@\"NEW jwToken %@\", newJWToken);\n    NSLog(@\"NEW refreshToken %@\", newRefreshToken);\n}];",
      "language": "objectivec"
    },
    {
      "code": "LoginAuthCore.sharedManager()?.refreshJWTokenForUser(with: \"jwToken\",\n                                             refreshToken: \"refreshToken\",\n                                                   result: { (newJWToken, newRefreshToken) in\n    print(\"Success Refresh jwToken & refreshToken\")\n})",
      "language": "swift"
    }
  ]
}
[/block]

In response you will receive new `JWTtokens`.

#### Get JWT for existing SDK users

During the app usage, there may be several scenarios when the app loses `JWTtoken`, for example if the a user changes a smartphone or logs out. BTW, that is a reason why we strongly recommend you to store the `deviceToken` on your backend side. `deviceToken` cannot be restored if it is lost!

We provide you with a simple re-authorization, a method that you can use to get a valid `JWTtoken` for a particular user throught providing `DeviceToken`
To use this mehod, you need `deviceToken`, `instanceId`, and `instanceKey` of which group the user belongs. in this case, `Devicetoken` works as a login, `instancekey` as a password. Then you can re-login the user and get a valid `JWTtoken` & `refreshToken`.

[block:code]
{
  "codes": [
    {
      "code": "[[LoginAuthCore sharedManager] getJWTokenForUserWithDeviceToken:@\"deviceToken\"\n                                                     instanceId:@\"instanceId\"\n                                                    instanceKey:@\"instanceKey\"\n                                                         result:^(NSString *jwToken, NSString *refreshToken) {\n    NSLog(@\"NEW JWT by DEVICETOKEN %@\", jwToken);\n    NSLog(@\"NEW REFRESHTOKEN by DEVICETOKEN %@\", refreshToken);\n}];",
      "language": "objectivec"
    },
    {
      "code": "LoginAuthCore.sharedManager()?.getJWTokenForUser(withDeviceToken: \"deviceToken\",\n                                                      instanceId: \"instanceId\",\n                                                     instanceKey: \"instanceKey\",\n                                                          result: { (jwToken, refreshToken) in\n    print(\"Success Getting New jwToken & refreshToken by DeviceToken\")\n})",
      "language": "swift"
    }
  ]
}
[/block]

In response, you will receive a new `jwToken` and `refreshToken`.

### Additional methods

#### Create DeviceToken with Parameters

Additionally, you can create a user's `deviceToken` and get the necessary keys (`JWTtoken`, `refreshToken` ) with additional parameters. This is not a required method, it just allows you to store the user profile in a different way. You can specify the below given parameters when creating a user's deviceToken:

* userEmail
* userPhone
* firstName
* lastName
* address
* birthday
* gender
* maritalStatus
* childrenCount
* clientId

[block:code]
{
  "codes": [
    {
      "code": "    [[LoginAuthCore sharedManager] createDeviceTokenForUserWithParametersAndInstanceId:@\"instanceId\"\n                                                                           instanceKey:@\"instanceKey\"\n                                                                                 email:@\"mail@mail.mail\"\n                                                                                 phone:@\"+10000000000\"\n                                                                             firstName:@\"TELEMATICS_USERNAME\"\n                                                                              lastName:@\"TELEMATICS_LASTNAME\"\n                                                                               address:@\"CITY\"\n                                                                              birthday:@\"\"\n                                                                                gender:@\"Male\"    // String Male/Female\n                                                                         maritalStatus:@\"1\"       // String 1/2/3/4 = \"Married\"/\"Widowed\"/\"Divorced\"/\"Single\"\n                                                                         childrenCount:@\"0\"       // String count 1-10\n                                                                              clientId:@\"idOptional\" result:^(NSString *deviceToken, NSString *jwToken, NSString *refreshToken) {\n        NSLog(@\"UserServiceResponce deviceToken %@\", deviceToken);\n        NSLog(@\"UserServiceResponce jwToken %@\", jwToken);\n        NSLog(@\"UserServiceResponce refreshToken %@\", refreshToken);\n    }];\n",
      "language": "objectivec"
    }
  ]
}
[/block]

##### You can always request information about the user profile anytime:

[block:code]
{
  "codes": [
    {
      "code": "    [[LoginAuthCore sharedManager] getUserProfileWithInstanceId:@\"instanceId\"\n                                                    instanceKey:@\"instanceKey\"\n                                                        jwToken:@\"jwToken\" result:^(NSString *email, NSString *phone, NSString *firstName, NSString *lastName, NSString *address, NSString *birthday, NSString *gender, NSString *maritalStatus, NSString *childrenCount, NSString *clientId) {\n        NSLog(@\"Success fetch user profile\");\n        //\n    }];",
      "language": "objectivec"
    }
  ]
}
[/block]

##### And also, update the user profile with the following method:

[block:code]
{
  "codes": [
    {
      "code": "    [[LoginAuthCore sharedManager] updateUserProfileWithParametersAndInstanceId:@\"instanceId\"\n                                                                    instanceKey:@\"instanceKey\"\n                                                                        jwToken:@\"jwToken\"\n                                                                          email:@\"mail@mail.mail\"\n                                                                          phone:@\"+10000000000\"\n                                                                      firstName:@\"TELEMATICS_USERNAME\"\n                                                                       lastName:@\"TELEMATICS_LASTNAME\"\n                                                                        address:@\"NEWCITY\"\n                                                                       birthday:@\"\"\n                                                                         gender:@\"Male\"  // String Male/Female\n                                                                  maritalStatus:@\"1\"  // String 1/2/3/4 = \"Married\"/\"Widowed\"/\"Divorced\"/\"Single\"\n                                                                  childrenCount:@\"5\"  // String count 1-10\n                                                                       clientId:@\"idOptionalNew\" result:^(NSString *result) {\n        NSLog(@\"Success update user profile\");\n    }];",
      "language": "objectivec"
    }
  ]
}
[/block]

Happy coding!

### Links

[Official product Web-page](https://app.damoov.com/)

[Official API services web-page](https://www.damoov.com/telematics-api/)

[Official API references](https://docs.telematicssdk.com/reference)

[Official ZenRoad web-page](https://www.damoov.com/telematics-app/)

[Official ZenRoad app for iOS](https://apps.apple.com/jo/app/zenroad/id1563218393)

[Official ZenRoad app for Android](https://play.google.com/store/apps/details?id=com.telematicssdk.zenroad\&hl=en\&gl=US)

[Official ZenRoad app for Huawei](https://appgallery.huawei.com/#/app/C104163115)

###### Copyright © 2020-2021 DATA MOTION PTE. LTD. All rights reserved.