Cordova SDK - 메소드 참조

Cordova SDK - 메소드 참조

이 포괄적인 참조 문서에는 Cordova 애플리케이션용 Singular SDK에서 사용 가능한 모든 메소드가 설명되어 있습니다. SDK는 초기화, 이벤트 추적, 구매 보고, 어트리뷰션, 데이터 개인정보 보호 규정 준수 및 SKAdNetwork 관리를 위한 기능을 제공합니다. 각 메소드에 대한 설명, 서명, 실제 사용 예시가 함께 제공되어 개발자가 Singular의 SDK 기능을 Cordova 애플리케이션에 연동하는 데 도움이 됩니다.

adRevenue

Singular.adRevenue 메서드

자세한 광고 데이터 정보로 광고 구매 이벤트를 추적합니다. 이 메서드를 사용하면 애플리케이션에 표시된 광고에서 발생한 구매을 다양한 파라미터와 함께 보고하여 광고 성과를 분류하고 분석할 수 있습니다.

시그니처

adRevenue(adData: Object): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Create ad data object with required fields
var adData = {
  ad_platform: 'AdMob',
  ad_currency: 'USD',
  ad_revenue: 0.05,
  ad_unit_id: 'ca-app-pub-1234567890123456',
  ad_type: 'Rewarded',
  ad_placement_name: 'level_complete'
};

// Track ad revenue event
Singular.adRevenue(adData);

clearGlobalProperties

Singular.clearGlobalProperties 메서드

이전에 설정된 모든 글로벌 속성을 제거합니다. 사용자가 애플리케이션에서 로그아웃할 때와 같이 전역 속성을 재설정해야 할 때 유용합니다.

서명

clearGlobalProperties(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Clear all global properties
Singular.clearGlobalProperties();

createReferrerShortLink

Singular.createReferrerShortLink 메서드

공유 및 어트리뷰션에 사용할 수 있는 리퍼러 정보가 포함된 짧은 링크를 생성합니다. 이 메서드는 사용자와 공유할 수 있는 추적 가능한 링크를 생성하여 설치 및 활동을 특정 리퍼럴 소스에 어트리뷰션할 수 있도록 합니다.

서명

createReferrerShortLink(
  url: string,
  refName: string,
  refId: string,
  passthroughParams: Object,
  resultHandler: Object
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Create a short link for referral
var resultHandler = {
  onSuccess: function(link) {
    console.log('Generated short link:', link);
    // Share the link with users
  },
  onError: function(error) {
    console.error('Error creating short link:', error);
  }
};

Singular.createReferrerShortLink(
  'https://sample.sng.link/B4tbmv8fp',
  'John Doe',
  'aq239897',
  { channel: 'sms', campaign: 'summer_promo' },
  resultHandler
);

customRevenue

Singular.customRevenue 메서드

지정된 이벤트 이름, 통화 및 금액으로 사용자 지정 구매 이벤트를 추적합니다. 이를 통해 사용자 지정 이벤트 이름으로 보다 구체적인 구매을 추적할 수 있습니다.

서명

customRevenue(
  eventName: string,
  currency: string,
  amount: number
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track a custom revenue event
Singular.customRevenue('premium_subscription', 'USD', 9.99);

customRevenueWithArgs

Singular.customRevenueWithArgs 메서드

지정된 이벤트 이름, 통화, 금액 및 추가 속성을 사용하여 사용자 지정 구매 이벤트를 추적합니다. 이를 통해 사용자 지정 매개변수를 사용하여 보다 상세한 구매 추적이 가능합니다.

서명

customRevenueWithArgs(
  eventName: string,
  currency: string,
  amount: number,
  args: Object
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track a custom revenue event with attributes
Singular.customRevenueWithArgs(
  'in_app_purchase',
  'USD',
  5.99,
  {
    product_id: 'com.app.gems_pack_small',
    quantity: 1
  }
);

event

Singular.event 메서드

지정된 이름의 이벤트를 추적합니다. 이 메서드를 사용하여 애플리케이션 내에서 사용자 행동과 참여를 추적하세요.

서명

event(eventName: string): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track a simple event
Singular.event('level_completed');

eventWithArgs

Singular.eventWithArgs 메서드

지정된 이름과 추가 사용자 정의 속성으로 이벤트를 추적합니다. 이 메서드를 사용하여 세부 매개변수로 사용자 행동을 추적합니다.

Signature

eventWithArgs(
  eventName: string,
  args: Object
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track an event with additional parameters
Singular.eventWithArgs('level_completed', {
  level_id: 5,
  score: 12500,
  time_spent: 120,
  difficulty: 'medium'
});

getGlobalProperties

Singular.getGlobalProperties 메서드

현재 설정된 모든 글로벌 속성을 검색합니다. 이 메서드는 SDK에 설정된 모든 글로벌 프로퍼티가 포함된 객체를 수신하는 콜백 함수를 받습니다.

서명

getGlobalProperties(success: Function): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Get all global properties
Singular.getGlobalProperties(function(properties) {
  console.log('Global properties:', properties);
});

getLimitDataSharing

Singular.getLimitDataSharing 메서드

현재 데이터 공유 제한 상태를 검색합니다. 이 메서드는 현재 데이터 공유가 제한되어 있는지 여부를 나타내는 부울을 수신하는 콜백 함수를 받습니다.

서명

getLimitDataSharing(success: Function): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Check if data sharing is limited
Singular.getLimitDataSharing(function(isLimited) {
  if (isLimited) {
    console.log('Data sharing is currently limited');
  }
});

handlePushNotification

Singular.handlePushNotification 메서드

어트리뷰션을 위한 푸시 알림 페이로드를 처리합니다. 앱이 푸시 알림을 수신할 때 이 메서드를 호출해야 Singular가 올바르게 어트리뷰션할 수 있습니다. 이 메서드는 iOS 전용입니다.

서명

handlePushNotification(pushNotificationPayload: Object): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Handle a received push notification (iOS only)
if (device.platform === 'iOS') {
  var userInfo = remoteMessage.data;
  Singular.handlePushNotification(userInfo);
}

iapPurchase

Singular.iapPurchase 메서드

플랫폼별 영수증 유효성 검사를 통해 인앱 구매의 구매을 추적하기 위한 인앱 구매(IAP) 객체를 생성합니다. 이 생성자는 iOS 앱스토어와 안드로이드 플레이스토어 거래의 구매 데이터를 처리하여 적절한 구매 어트리뷰션 및 영수증 확인을 위해 데이터 형식을 지정합니다.

서명

function SingularIAP(product: Object): SingularIAP

사용 예시

JavaScript
var SingularIAP = require('./SingularIAP');

// Example for Android Play Store purchase
var androidProduct = {
  currency: 'USD',
  price: '$4.99',
  id: 'com.app.premium_gems',
  transaction: {
    type: 'android-playstore',
    receipt: 'eyJvcmRlcklkIjoiR1BBLjEyMzQ...',
    signature: 'signature_string_here'
  }
};

var androidIAP = new SingularIAP(androidProduct);

// Example for iOS App Store purchase
var iosProduct = {
  currency: 'USD',
  price: '$4.99',
  id: 'com.app.premium_gems',
  transaction: {
    type: 'ios-appstore',
    appStoreReceipt: 'MIITtQYJKoZIhvcNAQcCoIITpj...',
    id: 'transaction_identifier_123'
  }
};

var iosIAP = new SingularIAP(iosProduct);

// The resulting object contains:
// - ppc: product currency
// - r: revenue amount (parsed from price string)
// - is_revenue_event: true
// Platform-specific fields:
// Android: ptr, receipt, receipt_signature
// iOS: ptr, pti, pk

init

Singular.init 메서드

지정된 구성으로 Singular SDK를 초기화합니다. 이 메서드는 다른 SDK 메서드보다 먼저 호출해야 합니다. 구성 객체에는 API 키, 비밀 번호 및 기타 선택적 설정이 포함되어야 합니다.

서명

init(singularConfig: SingularConfig): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;
var SingularConfig = cordova.plugins.SingularCordovaSdk.SingularConfig;

// Create and configure the SDK
var config = new SingularConfig('YOUR_API_KEY', 'YOUR_SECRET');

// Initialize the SDK
Singular.init(config);

isAllTrackingStopped

Singular.isAllTrackingStopped 메서드

모든 추적이 중지되었는지 여부를 확인합니다. 이 메서드는 현재 추적 상태를 나타내는 부울을 수신하는 콜백 함수를 받습니다.

서명

isAllTrackingStopped(success: Function): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Check if tracking is stopped
Singular.isAllTrackingStopped(function(isStopped) {
  if (isStopped) {
    console.log('All tracking is currently stopped');
  }
});

limitDataSharing

Singular.limitDataSharing 메서드

데이터 공유 제한 상태를 설정합니다. 이 메서드를 사용하면 제3자와 공유되는 데이터를 제한하여 개인정보 보호 규정을 준수할 수 있습니다.

서명

limitDataSharing(value: boolean): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Enable data sharing limitation
Singular.limitDataSharing(true);

resumeAllTracking

Singular.resumeAllTracking 메서드

중지된 모든 추적 활동을 재개합니다. 사용자가 다시 옵트인할 때 추적을 다시 활성화하려면 이 메서드를 사용합니다.

서명

resumeAllTracking(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Resume tracking when user opts back in
Singular.resumeAllTracking();

revenue

Singular.revenue 메서드

지정된 통화와 금액으로 구매 이벤트를 추적합니다. 추가 속성 없이 구매을 추적하는 기본 방법입니다.

서명

revenue(
  currency: string,
  amount: number
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track a simple revenue event
Singular.revenue('USD', 9.99);

revenueWithArgs

Singular.revenueWithArgs 메서드

지정된 통화, 금액 및 추가 속성으로 구매 이벤트를 추적합니다. 이를 통해 사용자 지정 매개변수를 사용하여 보다 상세한 구매 추적이 가능합니다.

서명

revenueWithArgs(
  currency: string,
  amount: number,
  args: Object
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Track a revenue event with attributes
Singular.revenueWithArgs(
  'USD',
  9.99,
  {
    product_id: 'premium_monthly',
    transaction_id: 'txn_12345'
  }
);

setCollectIpv6Address

Singular.setCollectIpv6Address 메서드

런타임에 기기의 공용 IPv6 주소 전송을 활성화하거나 비활성화합니다. 수집은 기본적으로 활성화되어 있으며, 중지하려면 false를 전달하십시오. init 이후에 호출하십시오. 초기화 전에는 효과가 없으므로 시작 값은 SingularConfig의 withCollectIpv6Address로 설정하십시오. Cordova SDK 1.10.0 이상에서 사용할 수 있습니다.

서명

setCollectIpv6Address(collectIpv6Address: boolean): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Stop collecting the IPv6 address
Singular.setCollectIpv6Address(false);

setCustomUserId

Singular.setCustomUserId 메서드

현재 세션에 대한 사용자 지정 사용자 ID를 설정합니다. 이를 통해 Singular 데이터를 자체 사용자 식별 시스템과 연결할 수 있습니다.

서명

setCustomUserId(userId: string): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Set custom user ID after login
Singular.setCustomUserId('user123456');

setGlobalProperty

Singular.setGlobalProperty 메서드

모든 후속 이벤트와 함께 전송될 전역 속성을 설정합니다. 이는 영구적인 사용자 속성이나 애플리케이션 상태를 추적하는 데 유용합니다. 이 메서드는 성공을 나타내는 부울을 수신하는 콜백 함수를 받아들입니다.

서명

setGlobalProperty(
  key: string,
  value: any,
  overrideExisting: boolean,
  success: Function
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Set a global property
Singular.setGlobalProperty(
  'user_tier',
  'premium',
  true,
  function(success) {
    if (success) {
      console.log('Global property set successfully');
    }
  }
);

setLimitAdvertisingIdentifiers

Singular.setLimitAdvertisingIdentifiers 메서드

광고 식별자(IDFA/GAID)를 제한할지 여부를 제어합니다. 개인정보 기본 설정 및 규정을 준수하려면 이 메서드를 사용합니다.

서명

setLimitAdvertisingIdentifiers(enabled: boolean): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Limit advertising identifiers
Singular.setLimitAdvertisingIdentifiers(true);

setUninstallToken

Singular.setUninstallToken 메서드

앱 제거 추적을 위한 푸시 알림 토큰을 설정합니다. 이를 통해 Singular는 푸시 알림 전달 실패를 모니터링하여 앱 제거를 추적할 수 있습니다.

서명

setUninstallToken(token: string): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Set the push notification token for uninstall tracking
Singular.setUninstallToken('your-fcm-or-apns-token-here');

skanGetConversionValue

Singular.skanGetConversionValue 메서드

현재 SKAdNetwork 전환 값을 가져옵니다. 이 메서드는 현재 전환 값을 숫자로 반환하는 콜백 함수를 받습니다. 이 메서드는 iOS 전용입니다.

서명

skanGetConversionValue(success: Function): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Get current SKAdNetwork conversion value (iOS only)
if (device.platform === 'iOS') {
  Singular.skanGetConversionValue(function(value) {
    console.log('Current conversion value:', value);
  });
}

skanRegisterAppForAdNetworkAttribution

Singular.skanRegisterAppForAdNetworkAttribution 메서드

앱을 SKAdNetwork 어트리뷰션에 등록합니다. 이 메서드는 앱 라이프사이클 초기에 호출하여 SKAdNetwork 추적을 활성화해야 합니다. 이 메서드는 iOS 전용입니다.

서명

skanRegisterAppForAdNetworkAttribution(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Register for SKAdNetwork attribution (iOS only)
if (device.platform === 'iOS') {
  Singular.skanRegisterAppForAdNetworkAttribution();
}

skanUpdateConversionValue

Singular.skanUpdateConversionValue 메서드

SKAdNetwork 전환 값을 업데이트합니다. 이 메서드는 SKAdNetwork 2.0-3.0에 사용되며 업데이트 성공 여부를 나타내는 부울을 수신하는 콜백 함수를 허용합니다. 이 메서드는 iOS 전용입니다.

서명

skanUpdateConversionValue(
  value: number,
  success: Function
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Update SKAdNetwork conversion value (iOS only)
if (device.platform === 'iOS') {
  Singular.skanUpdateConversionValue(3, function(success) {
    if (success) {
      console.log('Conversion value updated successfully');
    }
  });
}

skanUpdateConversionValues

Singular.skanUpdateConversionValues 메서드

세밀한 값, 거친 값, 잠금 상태로 SKAdNetwork 4.0 전환 값을 업데이트합니다. 이 메서드는 iOS 16.1 이상용이며 성공 여부를 나타내는 부울을 수신하는 콜백 함수를 허용합니다. 이 메서드는 iOS 전용입니다.

서명

skanUpdateConversionValues(
  value: number,
  coarse: number,
  lock: boolean,
  success: Function
): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Update SKAdNetwork 4.0 conversion values (iOS 16.1+)
if (device.platform === 'iOS') {
  Singular.skanUpdateConversionValues(
    5,     // fine value (0-63)
    1,     // coarse value (0=low, 1=medium, 2=high)
    false, // lock
    function(success) {
      if (success) {
        console.log('Conversion values updated successfully');
      }
    }
  );
}

stopAllTracking

Singular.stopAllTracking 메서드

모든 추적 활동을 중지합니다. 이 메서드를 사용하면 사용자가 옵트아웃할 때 또는 개인 정보 보호를 준수하기 위해 추적을 비활성화할 수 있습니다.

서명

stopAllTracking(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Stop tracking when user opts out
Singular.stopAllTracking();

trackingOptIn

Singular.trackingOptIn 메서드

사용자가 추적에 옵트인했음을 나타냅니다. 사용자가 추적 및 데이터 수집에 명시적으로 동의할 때 이 메서드를 호출합니다.

서명

trackingOptIn(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// User has opted in to tracking
Singular.trackingOptIn();

trackingUnder13

Singular.trackingUnder13 메서드

사용자가 13세 미만임을 나타냅니다. 이 메서드를 호출하면 13세 미만 사용자에 대한 COPPA 및 기타 규정을 준수할 수 있습니다.

서명

trackingUnder13(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Notify Singular the user is under 13 years old
Singular.trackingUnder13();

unsetCustomUserId

Singular.unsetCustomUserId 메서드

이전에 설정된 사용자 지정 사용자 아이디를 제거합니다. 사용자가 로그아웃하거나 이벤트를 더 이상 현재 사용자 ID에 연결하지 않으려는 경우 이 메서드를 호출하세요.

서명

unsetCustomUserId(): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Clear custom user ID when user logs out
Singular.unsetCustomUserId();

unsetGlobalProperty

Singular.unsetGlobalProperty 메서드

이전에 설정된 전역 속성을 제거합니다. 특정 글로벌 프로퍼티를 더 이상 이벤트와 함께 전송하지 않으려면 이 메서드를 호출하세요.

서명

unsetGlobalProperty(key: string): void

사용 예시

JavaScript
var Singular = cordova.plugins.SingularCordovaSdk;

// Remove a global property
Singular.unsetGlobalProperty('user_tier');