- Uninstall
- User invite
- Collect IDFA with ATTrackingManager
- iOS: forwarding launch options (
handleLaunchOptions)
Code sample for AppDelegate.swift: Example:
import UIKit
import Capacitor
import AppsFlyerLib
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10, *) {
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
application.registerForRemoteNotifications()
}
else if #available(iOS 9, *) {
UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
UIApplication.shared.registerForRemoteNotifications()
}
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
AppsFlyerLib.shared().registerUninstall(deviceToken)
}
}Note : If you use this method you will need to collect the APNs token using a third party platform of your choice.
AppsFlyer.updateServerUninstallToken({token: 'replace_with_token'});Read more about Uninstall register: Appsflyer SDK support site
There are 2 main approaches of enabling uninstall measurement for Android:
- Use FirebaseMessagingService from AppsFlyer SDK - only needs change to AndroidManifest
- Manually pass token to SDK - should be used if you have custom logic in place when token us updated.
For more info on Android Uninstall setup check out the guide here.
If the sole purpose of integrating FCM is to measure uninstalls in AppsFlyer, use appsFlyer.FirebaseMessagingServiceListener service, embedded in the SDK. This extends the FirebaseFirebaseMessagingService class, used to receive the FCM Device Token.
To add appsFlyer.FirebaseMessagingServiceListener service to the app, place the following in your AndroidManifest.xml :
<application
<!-- ... -->
<service
android:name="com.appsflyer.FirebaseMessagingServiceListener">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<!-- ... -->
</application>Note : If you use this method you will need to collect the FCM's token using a third party platform of your choice.
AppsFlyer.updateServerUninstallToken({token: 'replace_with_token'});Read more about Android Uninstall Tracking: Appsflyer SDK support site
AppsFlyer allows you to attribute and record installs originating from user invites within your app. Allowing your existing users to invite their friends and contacts as new users to your app can be a key growth factor for your app.
Example:
AppsFlyer.generateInviteLink({
parameters: {
campaign: 'appsflyer_plugin',
channel: 'sms',
userParams: { code: '1256abc', page: '152' },
},
})
.then(link => alert('user invite link: ' + link))
.catch(e => alert('user invite error: ' + e));- Add the
AppTrackingTransparencyframework to your xcode project. - In the
Info.plist:- Add an entry to the list: Press + next to
Information Property List. - Scroll down and select
Privacy - Tracking Usage Description. - Add as the value the wording you want to present to the user when asking for permission to collect the IDFA.
- Add an entry to the list: Press + next to
- Request tracking authorization yourself, inside the session-ready callback and before calling
start()(see the code sample below) — there is noinit()-time option for this anymore. - In the
CAPBridgeViewController.swiftfile, add:
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization { (status) in }
}
}For more info visit our Support integration guide Here
You can use this plugin: capacitor-plugin-app-tracking-transparency
Note: init() no longer has a built-in waitForATTUserAuthorization option — request the
ATT permission yourself, inside the session-ready callback, before calling start().
import {AppsFlyer} from 'appsflyer-capacitor-plugin';
constructor(public platform: Platform) {
this.platform.ready().then(async () => {
await AppsFlyer.init({ devKey, appId });
AppsFlyer.registerSessionReadyListener(async () => {
await AppTrackingTransparency.requestPermission();
AppsFlyer.start();
});
});
}Capacitor auto-wires URL-open and universal-link forwarding for you — AppsFlyerPlugin.swift
already observes Capacitor's capacitorOpenURL/capacitorOpenUniversalLink notifications and
forwards them into the SDK. There is no Capacitor-side notification for application(_:didFinishLaunchingWithOptions:),
though, so that one call must be added by hand in your app's AppDelegate.swift:
import UIKit
import Capacitor
import AppsFlyerPlugin
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
AppsFlyerAttribution.shared.handleLaunchOptions(launchOptions)
return true
}
}Add this line even if you don't otherwise hand-integrate AppDelegate.swift — unlike the URL/deep-link
forwarding above, this one has no auto-wired equivalent and won't fire without it.