aws-sdk-ios icon indicating copy to clipboard operation
aws-sdk-ios copied to clipboard

How do I reset the AWSPinpoint endpoints when data is migrated with Quick Start?

Open jormungand2006 opened this issue 1 year ago • 2 comments

State your question ・How do I reset the AWSPinpoint endpoints (held in UserDefaults and Keychain) when data is migrated with Quick Start on the iPhone?

My understanding is that AWSPinpoint stores the endpointId in both UserDefaults and Keychain after generating it. https://github.com/aws-amplify/aws-sdk-ios/blob/main/AWSPinpoint/AWSPinpointTargetingClient.m#L142

If an app on device 1 that already stores endpointId: AAA is migrated to device 2 with QuickStart, the KeyChain value is not transferred, but the UserDefaults value is, so, If the user does not initialize terminal device 1 afterwards, there will be multiple endpoints with EndpointId: AAA, is this the intended behavior?

I don't want the endpoints to be taken over, so I would like to reset the EndpointId when the app is launched on device 2. Is such a method provided?

Which AWS Services are you utilizing? ・AWSPinpoint

Provide code snippets (if applicable)

Environment(please complete the following information):

  • SDK Version: AWSSDKiOSV2: 2.33.1 (AWSPinpoint) https://github.com/aws-amplify/aws-sdk-ios-spm.git
  • Dependency Manager: SPM
  • Swift Version : 5

jormungand2006 avatar Jan 24 '24 03:01 jormungand2006

Hi @jormungand2006, Thanks for opening the issue. Our team will look into it and provide an update.

5d avatar Jan 27 '24 06:01 5d

Hi @jormungand2006! The endpointId is only stored in UserDefaults if it cannot be stored in the Keychain. However, on every app launch there is a migration attempt, i.e. if there is no endpointId in the Keychain but there is one in UserDefaults, it will be moved to the Keychain and deleted from UserDefaults. The relevant code is here

It is possible that a user might end up in the situation you mentioned if the SDK fails to save their endpointId to the Keychain on each launch, but it seems highly unlikely. In any case, here you can find the key used to store it in UserDefaults, in case you wish to delete it yourself if you detect that a new device is using your app.

ruisebas avatar Feb 23 '24 23:02 ruisebas