Get message center data

Prev Next

The getMessageCenterData method allows you to retrieve the pushes that you sent to your users in the past three months in a defined range and quantity.

ParameterData Type
limitInteger
startDateDate
endDateDate
your title goes here
Make sure that you pass the values for startDate and endDate in timestamps.

getMessageCenterData for logged-in users

This method type helps you get the messages delivered to the users who are logged in to the app. 

Method signature

+(void)getMessageCenterDataWithLimit:(int)limit startDate:(NSDate *)startDate endDate:(NSDate *)endDate success:(void (^)(NSArray *messageCenterData))completionBlock;

Method example

The following code snippets show how to use this method in Objective-C and Swift.

  NSDate *today = [NSDate date];
  NSDate *yesterday = [today dateByAddingTimeInterval: -86400.0];
  [Insider getMessageCenterDataWithLimit:20 startDate:yesterday endDate:today success:^(NSArray *messageCenterData) {
        NSLog(@"%@", messageCenterData);
    }];
let today = Date()
var oneDayBefore = DateComponents()
oneDayBefore.setValue(-1, for: .day)
let yesterday = Calendar.current.date(byAdding: oneDayBefore, to: today)
        
Insider.getMessageCenterData(withLimit: 20, start: yesterday, end: today) { (messageCenterData) in
    // Handle here
}
Your title goes here
The getMessageCenterData method functions with a user-based mechanism. For example, if user A and user B log into the app on the same device, each user will see the push notifications they received.

getMessageCenterData with identifiers signature

This method type helps you get message data with default and custom identifiers of different users.

Method signature

+ (void)getMessageCenterDataWithLimit:(NSInteger)limit                                                                                                                         
                                startDate:(nonnull NSDate *)startDate                                                                                                              
                                  endDate:(nonnull NSDate *)endDate                                                                                                                
                              identifiers:(InsiderIdentifiers *)identifiers                                                                                                        
                                  success:(nonnull void (^)(NSArray<NSDictionary<NSString *, id> *> * _Nonnull))completionBlock;
// Callback form
    Insider.getMessageCenterData(limit:startDate:endDate:identifiers:success:)

Method example

InsiderIdentifiers *identifiers = [[InsiderIdentifiers alloc] init];
    identifiers
        .addEmail(@"child@insiderone.com")
        .addPhoneNumber(@"+123456789012");
    NSDate *start = [NSDate dateWithTimeIntervalSinceNow:-30 * 24 * 3600]; // 30 days ago
    NSDate *end   = [NSDate date];
    [Insider getMessageCenterDataWithLimit:50
                                 startDate:start
                                   endDate:end
                               identifiers:identifiers
                                   success:^(NSArray<NSDictionary<NSString *, id> *> *data) {
        NSLog(@"Fetched %lu messages", (unsigned long)data.count);
    }];
// callback form
    let identifiers = InsiderIdentifiers()
    identifiers
        .addEmail("child@insiderone.com")
        .addPhoneNumber("+123456789012")
    let start = Date(timeIntervalSinceNow: -30 * 24 * 3600)
    Insider.getMessageCenterData(
        limit: 50,
        startDate: start,
        endDate: .now,
        identifiers: identifiers
    ) { data in
        print("Fetched \(data.count) messages")
    }