Updates handling

Updates from the backend

If backend want to notify client application that something was changed, TLUpdate will be sent.

Please check TPDUpdatesService class for more details. You can subscribe for related notifications to handle updates inside your app implementation.

Updates from SDK

TPDMessagingContext.sharedContext instance provides TPDDboManager subclasses that allows you to handle updates from SDK:

  • TPDAccountDboManager

  • TPDBusinessProfileDboManager

  • TPDMessRelDboManager

  • TPDRecentCallsDboManager

  • TPDScheduledCallsDboManager

  • TPDScheduledMeetingsDboManager

  • TPDSpecializationDboManager

  • TPDUserDboManager

Code example (handle username changed):

//inside UIViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    int32_t orgId = self.tpd_organizationId;
    
    TPDOrganizationContext *organizationContext = [[TPDMessagingContext sharedContext] contextForOrganization:orgId];
    
    [organizationContext.userDboManager addObserver:self];
}

#pragma mark <TPDDboManagerObserver>

- (void)dboManager:(nonnull TPDDboManager *)manager observeChangesForType:(TPDDboManagerChangeType)changesType 
      withUserInfo:(nonnull NSDictionary *)userInfo
{
    switch (changesType) {
        case TPDDboManagerChangeUpdate: {
            TPDDboManagerUpdater updater = userInfo[TPDDboManagerUpdaterKey];

            if (!updater) {
                return;
            }
            
            let oldUsername = _user.username;
            
            if (updater(_user)) {
                let newUsername = _user.username;

                if (newUsername.length == 0) {
                    [self doneActionWithSender:nil];
                } else if (![oldUsername isEqualToString:newUsername]) {
                    [self reloadQRCodeAnimated:YES];
                }
            }
            
            break;
        }
        case TPDDboManagerChangeDelete:
        case TPDDboManagerChangeNew: {
            //do nothing
            break;
        }
    }
}

Last updated