From 5e1d301aacb2efa1a5c4dcd1686012da5bc24654 Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker <33703490+BrandonStalnaker@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:29:24 -0400 Subject: [PATCH] feat: Update External iD on Initialization (#91) --- Sources/mParticle-Appboy/MPKitAppboy.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Sources/mParticle-Appboy/MPKitAppboy.m b/Sources/mParticle-Appboy/MPKitAppboy.m index 8205a8b..5225fd5 100644 --- a/Sources/mParticle-Appboy/MPKitAppboy.m +++ b/Sources/mParticle-Appboy/MPKitAppboy.m @@ -377,6 +377,9 @@ - (void)start { [self->appboyInstance setInAppMessagePresenter:inAppMessageUI]; #endif + FilteredMParticleUser *currentUser = [[self kitApi] getCurrentUserWithKit:self]; + [self updateUser:currentUser request:currentUser.userIdentities]; + self->_started = YES; dispatch_async(dispatch_get_main_queue(), ^{ @@ -818,26 +821,26 @@ - (nonnull MPKitExecStatus *)setUserAttribute:(nonnull NSString *)key values:(no } - (nonnull MPKitExecStatus *)onIdentifyComplete:(FilteredMParticleUser *)user request:(FilteredMPIdentityApiRequest *)request { - return [self updateUser:user request:request]; + return [self updateUser:user request:request.userIdentities]; } - (nonnull MPKitExecStatus *)onLoginComplete:(FilteredMParticleUser *)user request:(FilteredMPIdentityApiRequest *)request { - return [self updateUser:user request:request]; + return [self updateUser:user request:request.userIdentities]; } - (nonnull MPKitExecStatus *)onLogoutComplete:(FilteredMParticleUser *)user request:(FilteredMPIdentityApiRequest *)request { - return [self updateUser:user request:request]; + return [self updateUser:user request:request.userIdentities]; } - (nonnull MPKitExecStatus *)onModifyComplete:(FilteredMParticleUser *)user request:(FilteredMPIdentityApiRequest *)request { - return [self updateUser:user request:request]; + return [self updateUser:user request:request.userIdentities]; } -- (nonnull MPKitExecStatus *)updateUser:(FilteredMParticleUser *)user request:(FilteredMPIdentityApiRequest *)request { +- (nonnull MPKitExecStatus *)updateUser:(FilteredMParticleUser *)user request:(NSDictionary *)userIdentities { MPKitExecStatus *execStatus = nil; - if (request.userIdentities) { - NSMutableDictionary *userIDsCopy = [request.userIdentities copy]; + if (userIdentities) { + NSMutableDictionary *userIDsCopy = [userIdentities copy]; NSString *userId; if (_configuration[userIdTypeKey]) {