Get Tag Updates (iOS)

This article describes how to get Tag updates with the iOS SDK.

Overview

There are four steps to implementing Tag updates using the iOS SDK.

  1. Define the location and map IDs where you'll be getting Tag updates.
  2. Add MRTagManagerDelegate and MRTagManager to the view controller.
  3. Configure the MRTagManager.
  4. Add the three delegate methods to the view controller's implementation.

Define the Location and Map IDs

In order to get Tag updates, you'll need to point the SDK at a location and map that have deployed Tags.

    #define APP_ID_US   @"Insert your location ID here"
    #define MAP_ID_US   @"Insert your map ID here"

Add Tag Manager to the View Controller

The following code is an example of how to enable the view controller to track Tags. MRTagManagerDelegate overloads the load/update/remove notifications. MRTagManager and its reference ensure that Tag tracking won't stop.

The code example is from the Meridian Samples app and the example methods not be relevant to your project.

    //    change:
    // @interface MSShowsPlacemarksViewController : MRMapViewController 
 <msexampleviewcontroller>
  
    //    to:
    @interface MSShowsPlacemarksViewController : MRMapViewController 
  <msexampleviewcontroller, mrtagmanagerdelegate="">
    @property (nonatomic, strong) MRTagManager *tagManager; 
  </msexampleviewcontroller,>
 </msexampleviewcontroller>

Configure the Tag Manager

Configure the Tag manager to track Tags.

The viewDidLoad method is from the Samples app. There are other valid places to configure the Tag manager.

    // Added to the view controllers’s implementation file.
    // Added to the viewDidLoad method:

    self.tagManager = [MRTagManager tagManagerForLocationID:self.mapView.mapKey.parent.identifier delegate:self];

    // To subscribe to a specific tag, use that Tag's MAC.
    self.tagManager.tagSubscriptions = @[[MRDTagIdentifierSubscription subscriptionWithIdentifier:@"Insert Tag MAC here"]];

    // To subscribe to all the Tags on a specific map, use the mapKey
    // self.tagManager.tagSubscriptions =
    //       @[[MRDMapTagSubscription subscriptionWithIdentifier:self.mapView.mapKey.identifier]];

    // Start watching the Tags.
    [self.tagManager startUpdatingTags];

Add Tag Methods to View Controller

Add the Tag delegate methods to the view controller's implementation to track updated, removed, and loaded Tags.

    // Add to the view controller’s implementation file.
    #pragma mark - MRTagManagerDelegate

    - (void)tagManager:(MRTagManager *)manager didLoadTags:(NSArray 
 <mrtag *="">
   *)tags {
        // implementation here
    }

    - (void)tagManager:(MRTagManager *)manager didUpdateTag:(MRTag *)tag {
        // implementation here
        NSLog(@"Tag Updated: <%f,%f> : %@", tag.point.x, tag.point.y, tag.name);
    }

    - (void)tagManager:(MRTagManager *)manager didRemoveTag:(MRTag *)tag {
        // implementation here
        NSLog(@"Tag Removed: <%f,%f> : %@", tag.point.x, tag.point.y, tag.name);
    }


 </mrtag>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.