Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 2.5 KB

File metadata and controls

54 lines (43 loc) · 2.5 KB
title Integration
category 5f9705393c689a065c409b23
parentDoc 645213236f53a00d4daa9230
order 3
hidden false

Basic integration of the SDK

Initialize the SDK to enable AppsFlyer to detect installations, sessions (app opens) and updates.

initSdk(options, success, error) was removed in 7.0.0. Initialization is now a Promise-only init(devKey, appId) call; the options it used to accept are now separate calls — see MIGRATION.md and RN_API.md — Initialization Flow for the full recommended order.

Parameter Description
devKey Your application devKey provided by AppsFlyer (required)
appId App ID you configured in your AppsFlyer dashboard (optional per the type signature, but recommended for iOS)

isDebug, onInstallConversionDataListener, onDeepLinkListener, and manualStart are no longer options on the init call — call enableDebug, registerConversionListener, and registerDeepLinkListener as separate methods instead, and always finish with an explicit start() (SDK7 never auto-starts).

import AppsFlyer from 'react-native-appsflyer';

const onDeepLink = (res) => { /* ... */ };

// registerDeepLinkListener is the one exception to "always after init()" — register it
// before init(), on both platforms. See RN_API.md — Initialization Flow.
AppsFlyer.registerDeepLinkListener({ onDeepLinking: onDeepLink });

AppsFlyer.init({ devKey: 'K2***********99', appId: '41*****44' });
AppsFlyer.enableDebug({ enabled: true });

// Register remaining listeners synchronously, before init's promise settles
AppsFlyer.registerConversionListener({
  onConversionDataSuccess: (res) => { /* ... */ },
  onConversionDataFail: (error) => { /* ... */ },
});

AppsFlyer.registerSessionReadyListener(() => {
  AppsFlyer.start().then(
    () => console.log('SDK started'),
    (err) => console.error('start failed', err)
  );
});

See RN_API.md — Initialization Flow for the full recommended call order and detailed explanation of why the order matters.