Heartbeat API Dokümantasyonu
Uygulamanızın test süreci boyunca aktif olduğunu doğrulamak için gerekli entegrasyon rehberi.
Google Play, uygulamanızın 12 tester tarafından kesintisiz 14 gün boyunca test edilmesini şart koşar. Vaktify, bu süreci "Heartbeat" (Nabız) sinyalleri ile takip eder. Uygulamanız her açıldığında (veya günde en az bir kez) Vaktify sunucularına bir sinyal göndermelidir.
Cihaz Eşleştirme (Pairing)
Test kullanıcısı uygulamayı ilk açtığında, Vaktify profilinden alacağı 6 haneli Pair Code'u uygulamanıza girer. Uygulamanız bu kodu ve cihazın benzersiz ID'sini sunucuya göndererek eşleşmeyi sağlar.
Günlük Sinyal (Heartbeat)
Eşleşme sağlandıktan sonra, uygulamanız her gün açıldığında sunucuya otomatik olarak sinyal gönderir. Bu sinyal, test kullanıcısının aktif olduğunu doğrular ve 14 günlük sayacı ilerletir.
1 Cihaz Eşleştirme (Pairing)
{
"pair_code": "123456", // Kullanıcının girdiği 6 haneli kod
"device_id": "unique_device_id_xxx", // Cihazın benzersiz ID'si (Android ID vb.)
"package_name": "com.company.appname" // Uygulamanızın paket adı
}
2 Günlük Sinyal (Heartbeat)
* Bu anahtarı Developer Dashboard > Uygulamalarım > Key Göster alanından alabilirsiniz.
{
"package_name": "com.company.appname", // Uygulamanızın paket adı
"device_id": "unique_device_id_xxx" // Eşleşmede kullanılan aynı Cihaz ID'si
}
{
"status": "success",
"message": "Heartbeat received.",
"data": {
"day_streak": 5,
"remaining_days": 9
}
}
// 1. Get Device ID
val deviceId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
// 2. Function to Send Request (Generic)
// 2. Function to Send Request
fun sendRequest(endpoint: String, jsonBody: String, token: String? = null) {
val client = OkHttpClient()
val json = MediaType.parse("application/json; charset=utf-8")
val body = RequestBody.create(json, jsonBody)
val requestBuilder = Request.Builder()
.url("https://vaktify.com/api/v1/" + endpoint)
.post(body)
if (token != null) {
requestBuilder.addHeader("X-App-Token", token)
}
val request = requestBuilder.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) { e.printStackTrace() }
override fun onResponse(call: Call, response: Response) {
// Handle Response
}
})
}
// Usage: Pairing (No token needed)
val pairJson = """{"pair_code": "123456", "device_id": "$deviceId", "package_name": "com.pkg"}"""
sendRequest("device-pair", pairJson)
// Usage: Heartbeat (Requires Token)
val hbJson = """{"package_name": "com.pkg", "device_id": "$deviceId"}"""
val appKey = "YOUR_APP_API_KEY_FROM_DASHBOARD"
sendRequest("heartbeat", hbJson, appKey)
// 1. Get Device ID
String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
// 2. Prepare JSON & Send (Simplified)
OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// Pairing (No Token)
String pairJson = String.format(
"{\"pair_code\":\"%s\", \"device_id\":\"%s\", \"package_name\":\"%s\"}",
userEnteredCode, deviceId, getPackageName()
);
RequestBody body = RequestBody.create(JSON, pairJson);
Request request = new Request.Builder()
.url("https://vaktify.com/api/v1/device-pair")
.post(body)
.build();
// Heartbeat (With Token)
String hbJson = String.format(
"{\"package_name\":\"%s\", \"device_id\":\"%s\"}",
getPackageName(), deviceId
);
Request hbRequest = new Request.Builder()
.url("https://vaktify.com/api/v1/heartbeat")
.header("X-App-Token", "YOUR_APP_API_KEY")
.post(RequestBody.create(JSON, hbJson))
.build();
// Execute request...
API Entegrasyonunu Test Et
Geliştirdiğiniz entegrasyonu canlıya almadan önce test aracımızı kullanarak doğrulayabilirsiniz.
Canlı Test Aracı →