Click or drag to resize

MobileMapPackageExpiration Property

Gets the expiration details for this mobile map package, if provided.

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public Expiration Expiration { get; }

Property Value

Type: Expiration
Remarks

Expiration details provide:

  • The package’s expiration date and time.
  • Whether the maps can be accessed after expiration.
  • Any messages relevant for the user.

These expiration details can be specified when the author creates a mobile map package using ArcGIS Pro (from version 2.4). This requires the ArcGIS Pro Publisher Extension. Mobile map packages created with the OfflineMapTask do not support expiration.

By publishing a package with expiration details, the author can control the experience an end-user has when they try to access information that is no longer valid. For example, for time limited data (such as major sporting events), the author can ensure that the data cannot be accessed after the expiry date.

During package loading, the ArcGIS Runtime will determine whether the mobile map package was authored with expiration. If so, then this property will be populated.

If the package has expired and was authored as PreventExpiredAccess, loading will fail and you will not be able to access the maps.The expiration details will be accessible for you to examine and/or communicate to the user.

Examples

WPF

Example Name: HonorMobileMapPackageExpiration

Access the expiration information of an expired mobile map package.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using System;
using System.Linq;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.HonorMobileMapPackageExpiration
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Honor mobile map package expiration date",
        category: "Map",
        description: "Access the expiration information of an expired mobile map package.",
        instructions: "Load the sample. 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 sample presents expiration information to the user.",
        tags: new[] { "expiration", "mmpk", "Featured" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("174150279af74a2ba6f8b87a567f480b")]
    public partial class HonorMobileMapPackageExpiration
    {
        public HonorMobileMapPackageExpiration()
        {
            InitializeComponent();
            Initialize();
        }

        private async void Initialize()
        {
            try
            {
                // Path to the mobile map package.
                string mobileMapPackagePath = DataManager.GetDataFolder("174150279af74a2ba6f8b87a567f480b", "LothianRiversAnno.mmpk");

                // Create a mobile map package.
                MobileMapPackage mobileMapPackage = new MobileMapPackage(mobileMapPackagePath);

                // Load the mobile map package.
                await mobileMapPackage.LoadAsync();

                // Check if the map package is expired.
                if (mobileMapPackage.Expiration?.IsExpired == true)
                {
                    // Get the expiration of the mobile map package.
                    Expiration expiration = mobileMapPackage.Expiration;

                    // Get the expiration message.
                    string expirationMessage = expiration.Message;

                    // Get the expiration date.
                    string expirationDate = expiration.DateTime.ToString("F");

                    // Set the expiration message.
                    ExpirationLabel.Text = $"{expirationMessage}\nExpiration date: {expirationDate}";

                    // Check if the map is accessible after expiration.
                    if (expiration.Type == ExpirationType.AllowExpiredAccess && mobileMapPackage.Maps.Count > 0)
                    {
                        // Set the mapview to the map from the mobile map package.
                        MyMapView.Map = mobileMapPackage.Maps[0];
                    }
                    else if (expiration.Type == ExpirationType.PreventExpiredAccess)
                    {
                        MessageBox.Show("The author of this mobile map package has disallowed access after the expiration date.", "Error");
                    }
                }
                else if (mobileMapPackage.Maps.Any())
                {
                    // Set the mapview to the map from the mobile map package.
                    MyMapView.Map = mobileMapPackage.Maps[0];
                }
                else
                {
                    MessageBox.Show("Failed to load the mobile map package.", "Error");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
XAML
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.HonorMobileMapPackageExpiration.HonorMobileMapPackageExpiration"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock
                x:Name="ExpirationLabel"
                Text="Map package not expired."
                TextWrapping="Wrap" />
        </Border>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
HonorMobileMapPackageExpirationAccess the expiration information of an expired mobile map package.