The scenario is someone makes a purchase without an apple login so I see the subscription in the sandbox with an anonymous ID.
Then they log in using sign in with apple. Since I now have the user ID I log in to RevenueCat with the new ID assuming it will be associated with the anonymous ID and the purchasing info returned will say the subscription is active. It doesn’t do the association and the entitlements are empty.
func handle(_ authResult: Result<ASAuthorization, Error>) {
print("Authorization HANDLE")
switch authResult {
case.success(let auth):
Logger.su.info("Authorization successful: \(auth)")
switch auth.credential {
case let credential as ASAuthorizationAppleIDCredential:
Logger.su.info("Authorization credential: \(credential) user:\(credential.user)")
Purchases.shared.logIn(credential.user) { (purchaserInfo, created, error) in
if let error = error {
Logger.pay.error("PurchaseViewModel:login:error:\(error.localizedDescription)")
}
else {
Logger.pay.error("PurchaseViewModel:login:succeeded:purchaserInfo:\(purchaserInfo.debugDescription)")
}
let subscription_active = purchaserInfo?.entitlementsnRevenueCatConstants.entitlementID]?.isActive == true
Task {
LoginManager.shared.handleSignIn(credential: credential)
}
onboarding.nextAfterLogin(isSubscriptionActive: subscription_active)
}
default:
Logger.su.info("Authorization default credential: \(auth.credential.description)")
}
Should this work? I need to do this logic here, so I know if a paywall should be displayed next if they don’t have an active subscription. Or should I do a restore transaction?