Period Tag for iOS app

You can add, remove, and get a list of installed tags on IncomingTags for enriched trips these are the same tags as on Incoming but already linked to a specific track. You can also delete, add, and get Tags already linked to a specific track.

Manage Tag methods

Add a new tag

-(void)addFutureTrackTag:(RPTag *)tag completion:(RPAPIITagCallback)callback;

remove tag

-(void)removeFutureTrackTag:(RPTag *)tag completion:(RPAPIITagCallback)callback;

get tag

-(void)getFutureTrackTag:(NSInteger)timestamp completion:(RPAPIITagGCallback)callback;

Remove all tags

-(void)removeAllFutureTrackTagsWithΠ‘ompletion:(RPAPIITagWCallback)callback;

Usage examples:

  • without completion: [[RPEntry instance].api addFutureTrackTag:tag completion:nil];
  • with completion: [[RPEntry instance].api addFutureTrackTag:tag completion:^(RPTagStatus status, RPTag *tag, NSInteger timestamp) {}];

Code Example:

[[RPEntry instance].api addFutureTrackTag:tag completion:nil];
[[RPEntry instance].api addFutureTrackTag:tag completion:^(RPTagStatus status, RPTag *tag, NSInteger timestamp) {}];
[[RPEntry instance].api getFutureTrackTag:0 completion:^(RPTagStatus status, NSArray<RPTag *> *tags, NSInteger timestamp) {
    for (RPTag *item in tags) {
        NSLog(@"%@", item.tag);
    }
}];
[[RPEntry instance].api removeFutureTrackTag:tag completion:^(RPTagStatus status, RPTag *tag, NSInteger timestamp) {}];
[[RPEntry instance].api removeAllFutureTrackTagsWithΠ‘ompletion:^(RPTagStatus status, NSInteger timestamp) {}];
func addTag(_ status: RPTagStatus, tag: RPTag!, timestamp: Int) {
        let json: [String : Any?] = [
            "status": String(describing: status),
            "tag": String(data: tag.toJSON() as! Data, encoding: .utf8),
            "activationTime": timestamp
        ]
}

func deleteTag(_ status: RPTagStatus, tag: RPTag!, timestamp: Int) {
        let json: [String : Any?] = [
            "status": String(describing: status),
            "tag": String(data: tag.toJSON() as! Data, encoding: .utf8),
            "deactivationTime": timestamp
        ]
}

func removeAll(_ status: RPTagStatus, timestamp: Int) {
        let json: [String : Any?] = [
            "status": String(describing: status),
            "time": timestamp
        ]
}

Status Delegate

Added new RPTagsServerStateDelegate to monitor Tag operation status

Tag operation status

typedef NS_ENUM(NSUInteger, RPTagStatus) {
    SUCCESS, // success for add or delete
    OFFLINE, // app in offline and operation saved in local database
    ERROR_WRONG_TIME, // operation canceled by server with wrong time(time from future)
    ERROR_TAG_OPERATION // operation canceled by server as duplicated or incorrect
};

Code Example:

@interface MyListener () <RPTagsServerStateDelegate> {}
@end

@implementation MyListener

- (instancetype)init {
    self = [super init];
    if (self) {
        [RPEntry instance].tagStateDelegate = self;
    }
    return self;
}

- (void)addTag:(RPTagStatus)status tag:(RPTag *)tag timestamp:(NSInteger)timestamp {
    NSString *str = @"";
    switch (status) {
        case SUCCESS:
            str = @"success for add or delete";
            break;
            
        case OFFLINE:
            str = @"app in offline and operation saved in local database";
            break;
                  
        case ERROR_WRONG_TIME:
            str = @"operation canceled by server with wrong time(time from future)";
            break;
            
        case ERROR_TAG_OPERATION:
            str = @"operation canceled by server as duplicated or incorrect";
            break;
            
        default:
            break;
    }
    NSLog(@"%@ - %@ - %ld", str, tag.toJSON, timestamp);
}

- (void)deleteTag:(RPTagStatus)status tag:(RPTag *)tag timestamp:(NSInteger)timestamp {
    NSString *str = @"";
    switch (status) {
        case SUCCESS:
            str = @"success for add or delete";
            break;
            
        case OFFLINE:
            str = @"app in offline and operation saved in local database";
            break;
                  
        case ERROR_WRONG_TIME:
            str = @"operation canceled by server with wrong time(time from future)";
            break;
            
        case ERROR_TAG_OPERATION:
            str = @"operation canceled by server as duplicated or incorrect";
            break;
            
        default:
            break;
    }
    NSLog(@"%@ - %@ - %ld", str, tag.toJSON, timestamp);
}

- (void)getTags:(RPTagStatus)status tags:(id)tags timestamp:(NSInteger)timestamp {
    NSString *str = @"";
    switch (status) {
        case SUCCESS:
            str = @"success for add or delete";
            break;
            
        case OFFLINE:
            str = @"app in offline and operation saved in local database";
            break;
                  
        case ERROR_WRONG_TIME:
            str = @"operation canceled by server with wrong time(time from future)";
            break;
            
        case ERROR_TAG_OPERATION:
            str = @"operation canceled by server as duplicated or incorrect";
            break;
            
        default:
            break;
    }
    NSLog(@"%@ - %@ - %ld", str, tags, timestamp);
}

- (void)removeAll:(RPTagStatus)status timestamp:(NSInteger)timestamp {
    NSString *str = @"";
    switch (status) {
        case SUCCESS:
            str = @"success for add or delete";
            break;
            
        case OFFLINE:
            str = @"app in offline and operation saved in local database";
            break;
                  
        case ERROR_WRONG_TIME:
            str = @"operation canceled by server with wrong time(time from future)";
            break;
            
        case ERROR_TAG_OPERATION:
            str = @"operation canceled by server as duplicated or incorrect";
            break;
            
        default:
            break;
    }
    NSLog(@"%@ - %ld", str, timestamp);
}

@end
func getTags(_ status: RPTagStatus, tags: Any!, timestamp: Int) {
        let _tags = tags as? RPTags

        var strTags = [String]()

        _tags?.tags.forEach { element in
            let str = String(data: element.toJSON() as! Data, encoding: .utf8)!
            strTags.append(str)
        }

        let json: [String : Any?] = [
            "status": String(describing: status),
            "tags": strTags,
            "time": timestamp
        ]
}