Belirli kullanıcılara veya kullanıcı gruplarına premium özellikleri manuel olarak açmak istiyorsanız, bunu Adapty API aracılığıyla yapabilirsiniz. Bu yöntem; promosyon kampanyaları, yatırımcı erişimi veya özel müşteri destek senaryoları için oldukça kullanışlıdır.
Bu kılavuzda, kullanıcıları nasıl tanımlayacağınızı ve onlara access level’ları programatik olarak nasıl vereceğinizi öğreneceksiniz.
Örnek kullanım senaryoları
Promo kodları: Kullanıcılar uygulamanızda geçerli bir promo kodu girdiğinde, onlara otomatik olarak premium özelliklere erişim verin.
Yatırımcı/beta tester erişimi: Özel nitelikleri kontrol ederek yatırımcılara veya beta testçilere premium erişim sağlayın.
Adım 1. Kullanıcıları tanımlayın
Adapty, kullanıcıları platformlar ve cihazlar arasında tanımlamak için customer_user_id kullanır. Bu, kullanıcıların uygulamayı yeniden yükledikten veya cihaz değiştirdikten sonra da erişimlerini korumasını sağlamak açısından kritik öneme sahiptir.
Bu ID’yi bir kez oluşturmanız yeterlidir. Kullanıcılar uygulamadan ilk kez kayıt olduğunda, SDK aktivasyonu sırasında customer user ID’yi iletebilir ya da SDK kaydolmadan önce aktif edildiyse identify metodunu kullanabilirsiniz.
SDK aktivasyonundan sonra yeni kullanıcıları tanımlarsanız, SDK önce anonim bir profil oluşturur (onsuz çalışamaz). identify’ı bir customer user ID ile çağırdığınızda yeni bir profil oluşturulur.
Bu davranış normaldir ve analitik doğruluğunu etkilemez. Daha fazla bilgi için buraya bakın.
do { try await Adapty.identify("YOUR_USER_ID") // Unique for each user} catch { // handle the error}
// User IDs must be unique for each userAdapty.identify("YOUR_USER_ID") { error in if let error { // handle the error }}
Adapty.identify("YOUR_USER_ID") { error -> // Unique for each user if (error == null) { // successful identify }}
// User IDs must be unique for each userAdapty.identify("YOUR_USER_ID", error -> { if (error == null) { // successful identify }});
try { await adapty.identify("YOUR_USER_ID"); // Unique for each user // successfully identified} catch (error) { // handle the error}
try { await Adapty().identify(customerUserId); // Unique for each user} on AdaptyError catch (adaptyError) { // handle the error} catch (e) {}
Adapty.Identify("YOUR_USER_ID", (error) => { // Unique for each user if(error == null) { // successful identify }});
Adapty.identify("YOUR_USER_ID") // Unique for each user .onSuccess { // successful identify } .onError { error -> // handle the error }
Bir kullanıcı customer_user_id ile tanımlandıktan sonra, sunucu taraflı API’yi kullanarak onlara access level verebilirsiniz. Bu API çağrısı, kullanıcıya gerçekten ödeme yapmadan ücretli özelliklere erişebilmesi için access level tanımlar.
Adapty kontrol panelinde özel bir nitelik (ör. Beta tester veya Investor) ekleyerek kullanıcı erişimini yönetebilirsiniz.
Uygulamanız başlatıldığında, erişimi otomatik olarak vermek için kullanıcı profilindeki bu niteliği kontrol edin.
Erişimi güncellemek için kontrol panelindeki niteliği değiştirmeniz yeterlidir.
API aracılığıyla erişim verildikten sonra kullanıcının profili otomatik olarak güncellenir. Abonelik durumunu kontrol etmek ve premium özelliklerin kilidini açmak için profilini çekin.
do { let profile = try await Adapty.getProfile() if profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive ?? false { // grant access to premium features }} catch {// handle the error}
Adapty.getProfile { result in if let profile = try? result.get() { // check the access if profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive ?? false { // grant access to premium features } }}
Adapty.getProfile { result -> when (result) { is AdaptyResult.Success -> { val profile = result.value // check the access if (profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive == true) { // grant access to premium features } } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Adapty.getProfile(result -> { if (result instanceof AdaptyResult.Success) { AdaptyProfile profile = ((AdaptyResult.Success<AdaptyProfile>) result).getValue(); // check the access if (profile.getAccessLevels().get("YOUR_ACCESS_LEVEL_ID") != null && profile.getAccessLevels().get("YOUR_ACCESS_LEVEL_ID").getIsActive()) { // grant access to premium features } } else if (result instanceof AdaptyResult.Error) { AdaptyError error = ((AdaptyResult.Error) result).getError(); // handle the error }});
try { const profile = await adapty.getProfile(); // check the access if (profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive) { // grant access to premium features }} catch (error) { // handle the error}
try { final profile = await Adapty().getProfile(); // check the access if (profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive ?? false) { // grant access to premium features }} on AdaptyError catch (adaptyError) { // handle the error} catch (e) {}
Adapty.GetProfile((profile, error) => { if (error != null) { // handle the error return; } // check the access if (profile.AccessLevels["YOUR_ACCESS_LEVEL_ID"]?.IsActive ?? false) { // grant access to premium features }});
Adapty.getProfile() .onSuccess { profile -> // check the access if (profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive == true) { // grant access to premium features } } .onError { error -> // handle the error }
try { const profile = await adapty.getProfile(); // check the access if (profile.accessLevels["YOUR_ACCESS_LEVEL_ID"]?.isActive) { // grant access to premium features }} catch (error) { // handle the error}