Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login/logut methods in ios #101

Closed
fury21 opened this issue Oct 15, 2023 · 1 comment
Closed

Login/logut methods in ios #101

fury21 opened this issue Oct 15, 2023 · 1 comment

Comments

@fury21
Copy link

fury21 commented Oct 15, 2023

Hi.
In my ios app there are authorization screens using mail and password. There are 2 states of the application: the user is logged in and not.

  1. When the application is launched and the user is not logged in (I do not have an email user), do I need to call the Append.stat(apiKey: "YOUR_API_KEY") method
  2. When the user has logged in, which method should be called, App hub.start(apiKey: "YOUR_API_KEY", userID: "YOUR_USER_ID") or Apphud.startManually(apiKey: "YOUR_API_KEY", userID: "YOUR_USER_ID", DeviceID: "YOUR_USER_ID")?
  3. When the user logs into the application, do I need to call the Append.logout() method?
  4. In case 1 when the application is launched and the user is not logged in and I do not call the App hub.start method(apiKey: "YOUR_API_KEY"), then I get the message <SKPaymentQueue: 0x60000044c460>: No observers found that response to "paymentQueue:shouldAddStorePayment:forProduct:", will not check for purchase intents.
  5. If the user logged out (Apphud.logout()) and then logged in again with the same mail, then on the Apphud website in the users section I see two users with the same mail. Is this normal?
  6. I understand correctly that if I called the AApphud.start(apiKey: "YOUR_API_KEY", userID: "YOUR_USER_ID"), made a subscription, then called the Apphud.logout() and then called the Apphud.start(apiKey: "YOUR_API_KEY", userID: "YOUR_USER_ID") but with a different USER ID, then if I try to restore purchases from the second user, the purchase made by the first user should not be restored from the second user?

Let me know how to correctly identify the user if the authorization system is used in the application, I'm confused :)

@vlr-code
Copy link
Collaborator

Hi @fury21
By default, Apphud SDK creates own unique UUID user identifiers for each device. On iOS, User ID is saved to keychain and persists after app reinstall, however on Android User ID is reset after each reinstall due to technical limitations. If you want Apphud to manage User ID for you (recommended), then just initialize SDK without passing any User ID. Apphud guarantees User ID uniqueness for each device.
You can also initialise SDK with custom Device ID. This should be used if you plan to use logout / login features. You are responsible for User ID uniqueness and User Merging in this case. Best practice is to pass the same identifier to Device ID and User ID.
You can update your user's ID at any time after SDK initialization. This can be useful if you get your User ID some time after launch -> Apphud.updateUserID
Log out method will clear all saved data and reset SDK to uninitialised state. You must initialize SDK again after this method call. Use this method if you have your own login-logout logic.

User Merging
By default, users are being merged only if their App Store Receipts match. For example, if Apphud has a customer A with App Store Receipt A and we receive a new request from customer B with App Store Receipt A, then both customers are merged into customer A and User ID of the latter one is changed to A.
In other words, Apphud merges users by their original transaction id.
The device ID is the main identifier that uniquely identifies a customer. So even if you initialize SDK with the same custom User ID on different devices, several new users with the same User ID will be created since they have different Device IDs.

@ren6 ren6 closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants