Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Honor mobile map package expiration date

Sample Viewer View Sample on GitHub

Access the expiration information of an expired mobile map package.

Use case

The data contained within a mobile map package (MMPK) may only be relevant for a fixed period of time. Using ArcGIS Pro, the author of an MMPK can set an expiration date to ensure the user is aware the data is out of date.

As long as the author of an MMPK has set an expiration date, the expiration date can be read even if the MMPK has not yet expired. For example, developers could also use this API to warn app users that an MMPK may be expiring soon.

How to use the sample

Load the app. The author of the MMPK used in this sample chose to set the MMPK's map as still readable, even if it's expired. The app presents expiration information to the user.

How it works

  1. Create a MobileMapPackage passing in the path to the mobile map package's location on the device.
  2. Load the mobile map package.
  3. Present Expiration information to the user with the Expiration.message and Expiration.dateTime properties, which are set by the map author.

Relevant API

  • Expiration
  • MobileMapPackage

Offline Data

Read more about how to set up the sample's offline data here.

Link Local Location
Lothian Rivers Anno MMPK <sdcard>/ArcGIS/Samples/MapPackage/LothianRiversAnno.mmpk


expiration, mmpk

Sample Code

import QtQuick 2.6
import Esri.ArcGISRuntime 100.9
import Esri.ArcGISExtras 1.1

Rectangle {
    width: 800
    height: 600

    property url dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/mmpk/"    
    property string expirationDate
    property string expirationTime
    property string expirationMessage

    // Create MapView
    MapView {
        id: mapView
        anchors.fill: parent

    Component.onCompleted: {

    // Create a Mobile Map Package and set the path
    MobileMapPackage {
        id: mmpk
        path: dataPath + "LothianRiversAnno.mmpk"

        // wait for the mobile map package to load
        onLoadStatusChanged: {
            // only proceed once the map package is loaded
            if (loadStatus !== Enums.LoadStatusLoaded) {

            if (mmpk.maps.length < 1) {

            // check if the package is expired
            if (expiration) {
                if (expiration.expired) {
                    const dateTime = expiration.dateTime;
                    expirationDate = dateTime.toISOString().split("T")[0];
                    expirationTime = dateTime.toISOString().split("T")[1].substring(0,8)
                    expirationMessage = expiration.message;

                    // return if access after expiration is not allowed
                    if (expiration.type === Enums.ExpirationTypePreventExpiredAccess)

            // set the map view's map to the first map in the mobile map package
   = mmpk.maps[0];

        onErrorChanged: {
            console.log("Mobile Map Package Error: %1 %2".arg(error.message).arg(error.additionalMessage));

    Rectangle {
        anchors {
            verticalCenter: parent.verticalCenter
            left: parent.left
            right: parent.right
        height: 100
        color: "#303030"
        opacity: 0.75
        visible: mmpk.expiration ? mmpk.expiration.expired : false

        Text {
            id: expirationText
            anchors.centerIn: parent
            width: parent.width
            horizontalAlignment: Text.AlignHCenter
            wrapMode: Text.WordWrap
            color: "white"
            text: "%1\nExpired on %2 at %3 UTC".arg(expirationMessage).arg(expirationDate).arg(expirationTime)