2. SDK Integration
Please make sure you have read all of steps before using FID functions
2.1 Initialization FID SDK
@import FTSDKCoreKit;
@import FTSDK;
// From v1.4.0, you need call @import AppsFlyerLib to config uninstall event
@import AppsFlyerLib;
// From v1.3.5, you need call [FIRApp configure] manually
@import FirebaseCore;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Your code ...
// From v1.3.5, you need call [FIRApp configure] manually
[FIRApp configure];
// Enable logging, disable when build Product
[FTSDKConfig setDebug:YES];
// Make sure choose environment match with license
FTSDKConfig.env = 1; // 0: Product, 1: Development
// You can turn on uninstall sanbox when in Development
// [AppsFlyerLib shared].useUninstallSandbox = true;
// Setting SDK language
[[FTSDKAppDelegate instance] setLanguage: 1]; // 0: Vietnamese, 1: English
// Turn off autologin if need (you need use FTSDK.requestAutoLogin function to check login manual)
// FTSDKConfig.autoLogin = NO;
// If you not using Info.plist key `FIDLicense`, then you can set FID license here
// Make sure license match with `BundleId` and `env`
[FTSDKConfig setSDKLicenseWithLicense:@"YOUR_SDK_LICENSE"];
// Setting analytics configs
[FTSDK didFinishLaunching:application with:launchOptions];
// Your code ...
// Setting notification
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
// Request ATT permission for tracking after request notification
[[FTSDKTracking instance] requestTrackingAuthorization];
}];
// Request notification permission
[application registerForRemoteNotifications];
// FIRMessaging delegate, remember to implement UIApplicationDelegate, FIRMessagingDelegate
[FIRMessaging messaging].delegate = self;
}
// Handle Universal Links for KOLs
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
if ([FTSDK continue:userActivity restorationHandler:restorationHandler]) {
return YES;
}
return NO;
}
// Handle callback when login with Facebook, Google,...
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if ([FTSDK application:app open:url options:options]) {
return YES;
}
return NO;
}
// Importance for notification and uninstall event
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[FIRMessaging messaging].APNSToken = deviceToken;
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
if (error != nil) {
NSLog(@"Error getting FCM registration token: %@", error);
} else {
NSLog(@"FCM registration token: %@", token);
}
}];
// Add Appsflyer Uninstall measurement
[[AppsFlyerLib shared] registerUninstall:deviceToken];
}
@end
2.2 Handle FID SDK Ready
2.3 Third Party Configs
2.3.1 Google
2.3.2 Facebook
Last updated