İndirme Doğrulama Entegrasyonu

Uygulamanıza ekleyeceğiniz basit kodlarla indirmeleri güvenle takip edin

Entegrasyon Adımları

1. Kampanya Linki Yapısı

Tüm indirme kampanyalarınız için aşağıdaki link formatını kullanın:

https://app.fenomoney.com/api/{kampanya_id}

Kampanya ID'nizi Fenomoney panelinizden alabilirsiniz.

2. Doğrulama Akışı

İndirme işlemi başarıyla tamamlandığında aşağıdaki kodu çalıştırın.
Fenomoney İndirme Doğrulama Akışı

Platform Entegrasyonları

Uygulamanızın platformuna göre entegrasyon kodu

Android

Kotlin ile entegrasyon

Kodu Göster
// Kotlin implementation
fun verifyFenomoneyDownload(context: Context, campaignId: String) {
    val url = "https://app.fenomoney.com/api/"
    val deviceId = Settings.Secure.getString(
        context.contentResolver,
        Settings.Secure.ANDROID_ID
    )
    
    // Implementation continues...
}
AndroidManifest.xml'de internet izni gereklidir.
iOS

Swift ile entegrasyon

Kodu Göster
// Swift implementation
func verifyFenomoneyDownload(campaignId: String) {
    guard let url = URL(string: "https://app.fenomoney.com/api/") else { return }
    let deviceId = UIDevice.current.identifierForVendor?.uuidString ?? ""
    
    // Implementation continues...
}
Info.plist'te ATS ayarı gereklidir.
Web

JavaScript ile entegrasyon

Kodu Göster
// JavaScript implementation
async function verifyFenomoneyDownload(campaignId) {
    const url = 'https://app.fenomoney.com/api/';
    const deviceId = localStorage.getItem('fenomoney_device_id') || 
                     generateDeviceId();
    
    // Implementation continues...
}
Flutter

Dart ile entegrasyon

Kodu Göster
// Flutter implementation
Future verifyFenomoneyDownload(String campaignId) async {
    final url = 'https://app.fenomoney.com/api/';
    final deviceInfo = DeviceInfoPlugin();
    
    // Implementation continues...
}
http ve device_info_plus paketleri gereklidir.
Kotlin ile Entegrasyon
import android.content.Context
import android.content.SharedPreferences
import android.provider.Settings
import okhttp3.*
import java.io.IOException
import java.util.*

fun getFenomoneyDeviceId(context: Context): String {
    val prefs: SharedPreferences = context.getSharedPreferences("fenomoney_prefs", Context.MODE_PRIVATE)
    var deviceId = prefs.getString("fenomoney_device_id", null)

    if (deviceId == null) {
        val androidId = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
        deviceId = UUID.nameUUIDFromBytes(androidId.toByteArray()).toString()
        prefs.edit().putString("fenomoney_device_id", deviceId).apply()
    }

    return deviceId
}

fun verifyFenomoneyDownload(context: Context, campaignId: String) {
    val url = "https://app.fenomoney.com/api/"
    val deviceId = getFenomoneyDeviceId(context)

    val formBody = FormBody.Builder()
        .add("campaign_id", campaignId)
        .add("device_info", deviceId)
        .build()

    val request = Request.Builder()
        .url(url)
        .post(formBody)
        .build()

    val client = OkHttpClient()
    client.newCall(request).enqueue(object : Callback {
        override fun onFailure(call: Call, e: IOException) {
            Log.e("Fenomoney", "Doğrulama hatası: ${e.message}")
        }

        override fun onResponse(call: Call, response: Response) {
            val body = response.body?.string()
            Log.d("Fenomoney", "Doğrulama sonucu: $body")
        }
    })
}
Dikkat: AndroidManifest.xml'de internet izni eklemeyi unutmayın:
<uses-permission android:name="android.permission.INTERNET" />
Kullanımı:
verifyFenomoneyDownload(context, "{KampanyaID}")
Swift ile Entegrasyon
import UIKit

func getFenomoneyDeviceId() -> String {
    let key = "fenomoney_device_id"
    if let id = UserDefaults.standard.string(forKey: key) {
        return id
    } else {
        let newId = UIDevice.current.identifierForVendor?.uuidString ?? UUID().uuidString
        UserDefaults.standard.set(newId, forKey: key)
        return newId
    }
}

func verifyFenomoneyDownload(campaignId: String) {
    guard let url = URL(string: "https://app.fenomoney.com/api/") else { return }

    let deviceId = getFenomoneyDeviceId()
    let params = "campaign_id=\(campaignId)&device_info=\(deviceId)"
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.httpBody = params.data(using: .utf8)
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")

    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            print("Fenomoney doğrulama hatası: \(error.localizedDescription)")
            return
        }

        guard let data = data else {
            print("Fenomoney: Cevap boş")
            return
        }

        let responseStr = String(data: data, encoding: .utf8) ?? "Boş"
        print("Fenomoney doğrulama sonucu: \(responseStr)")
    }
    task.resume()
}
iOS 14+ için Info.plist'e ekleyin:
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
Kullanımı:
verifyFenomoneyDownload(campaignId: "{KampanyaID}")
JavaScript ile Entegrasyon
const getFenomoneyDeviceId = () => {
    const key = 'fenomoney_device_id';
    let deviceId = localStorage.getItem(key);
    
    if (!deviceId) {
        // Generate a unique ID if not exists
        deviceId = 'web-' + Math.random().toString(36).substr(2, 9) + 
                   '-' + Date.now().toString(36);
        localStorage.setItem(key, deviceId);
    }
    
    return deviceId;
};

const verifyFenomoneyDownload = async (campaignId) => {
    const url = 'https://app.fenomoney.com/api/';
    const deviceId = getFenomoneyDeviceId();
    
    try {
        const response = await fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: new URLSearchParams({
                campaign_id: campaignId,
                device_info: deviceId
            })
        });
        
        const data = await response.json();
        console.log('Fenomoney doğrulama sonucu:', data);
        return data;
    } catch (error) {
        console.error('Fenomoney doğrulama hatası:', error);
        throw error;
    }
};
Kullanımı:
verifyFenomoneyDownload('KampanyaID').then(response => { ... });
Flutter ile Entegrasyon
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'dart:convert';

Future getFenomoneyDeviceId() async {
  final prefs = await SharedPreferences.getInstance();
  String? deviceId = prefs.getString('fenomoney_device_id');

  if (deviceId == null) {
    final deviceInfo = DeviceInfoPlugin();
    String rawId;

    if (Theme.of(navigatorKey.currentContext!).platform == TargetPlatform.android) {
      final androidInfo = await deviceInfo.androidInfo;
      rawId = androidInfo.androidId ?? '';
    } else if (Theme.of(navigatorKey.currentContext!).platform == TargetPlatform.iOS) {
      final iosInfo = await deviceInfo.iosInfo;
      rawId = iosInfo.identifierForVendor ?? '';
    } else {
      rawId = DateTime.now().millisecondsSinceEpoch.toString();
    }

    deviceId = rawId.hashCode.toString();
    await prefs.setString('fenomoney_device_id', deviceId);
  }

  return deviceId;
}

Future verifyFenomoneyDownload(String campaignId) async {
  final url = Uri.parse('https://app.fenomoney.com/api/');
  final deviceId = await getFenomoneyDeviceId();

  final response = await http.post(url, body: {
    'campaign_id': campaignId,
    'device_info': deviceId,
  });

  if (response.statusCode == 200) {
    print('Doğrulama sonucu: ${response.body}');
  } else {
    print('Doğrulama hatası: ${response.statusCode}');
  }
}
Dikkat: `pubspec.yaml` dosyanıza aşağıdaki paketleri eklemeyi unutmayın:
dependencies:
  http: ^0.13.0
  shared_preferences: ^2.0.15
  device_info_plus: ^9.0.2
Kullanımı:
await verifyFenomoneyDownload("{KampanyaID}");

Sık Sorulan Sorular

Fenomoney doğrulama token'ları 1 saat boyunca geçerlidir. Süre dolduğunda yeni bir istek gereklidir.

https://app.fenomoney.com/api adresini kullanarak test yapabilirsiniz. Test kampanya ID'leri için dev@fenomoney.com ile iletişime geçin.

HTTP 400 - Geçersiz token
HTTP 429 - Çok fazla istek
HTTP 500 - Sunucu hatası
HTTP 200 - Başarılı
Hata mesajlarını Fenomoney loglarınıza kaydedip support@fenomoney.com'a bildirin.

Uygulamanızın tek seferlik kullanıcıya gösterilen başlangıç ekranlarından birinde sınıf olarak çağrılıp çalıştırılabilir. Kullanıcı eğer uygulamanızı indirip kaydolursa, kaydolma ekranına yada varsa SMS doğrulama ekranına bu kodları ekleyip kullanabilirsiniz. Aksi durumdaki eklemeler sürekli giriş çıkış olduğundan dolayı teknik olarak giren ve çıkan tüm kullanıcıları uygulamanızı indirdi olarak sayabilir. Splash ekranı veya Ana Ekran gibi kısımlara bu kodları eklemekten kaçının. Uygulamanızın ilk kuruluğunda nasıl kullanılır tarzındaki ekranlarına ekleyebilirsiniz.

Yardıma mı ihtiyacınız var?

Entegrasyon sürecinde sorun yaşarsanız Fenomoney destek ekibimiz hazır!