capacitor-appsflyer
v1.1.2
Published
Appsflyer capacitor plugin
Downloads
31
Readme
Capacitor AppsFlyer plugin for Android and iOS
Currently only works on ios, but android support will be coming soon
Available methods:
setCurrencyCode()
setСustomerUserID()
anonymizeUser()
setIsStopped()
getAppsFlyerUID()
logEvent()
getSdkVersion()
setAppInviteOneLinkID()
generateInviteLink()
logCrossPromotionImpression()
logCrossPromotionAndOpenStore()
setSharingFilter()
setSharingFilterForAllPartners()
disableCollectASA()
setDisableAdvertisingIdentifier()
setOneLinkCustomDomains()
enableFacebookDeferredApplinks()
setPhoneNumber()
setUserEmails()
validateAndLogInAppPurchase()
setUseReceiptValidationSandbox()
setHost()
addPushNotificationDeepLinkPath()
setResolveDeepLinkURLs()
disableSKAD()
Usage example:
- In
AppDelegate.swift
(usuallyios/App/App/AppDelegate.swift
)
...
import AppsFlyerLib
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
...
func applicationDidBecomeActive(_: UIApplication) {
Appsflyer.shared.applicationDidBecomeActive()
}
...
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
...
Appsflyer.shared.application(open: url, options: options)
...
}
...
func application(_: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
...
Appsflyer.shared.application(continue: userActivity, restorationHandler: restorationHandler)
...
}
...
func application(_: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
Appsflyer.shared.application(didReceiveRemoteNotification: userInfo)
}
...
func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
...
Appsflyer.shared.application(didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
...
}
...
}
- In your module (e.g.
app.module.ts
)
...
import { Appsflyer } from 'capacitor-appsflyer'
@NgModule({
...
providers: [
...
Appsflyer,
],
})
export class AppModule {}
- In your main component (e.g.
app.component.ts
)
...
import { Appsflyer } from 'capacitor-appsflyer'
@Component()
export class AppComponent {
constructor(private appsflyer: Appsflyer) {
this.platform
.ready()
.then(() => {
this.appsflyer.addListener('onConversionDataSuccess', (data) => {
console.log('AppsflyerPlugin onConversionDataSuccess', data)
})
})
}
}
BREAKING CHANGES in 1.x.x version
AppsFlyer proxy-class has been removed.
Migrate:
In
ios/App/App/AppDelegate.swift
, update the following:
func applicationDidBecomeActive(_: UIApplication) {
- Appsflyer.shared.applicationDidBecomeActive()
+ AppsFlyerLib.shared().start()
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
- Appsflyer.shared.application(open: url, options: options)
+ AppsFlyerLib.shared().handleOpen(url, options: options)
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
func application(_ app: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
- Appsflyer.shared.application(continue: userActivity, restorationHandler: restorationHandler)
+ AppsFlyerLib.shared().continue(userActivity, restorationHandler: nil)
return ApplicationDelegateProxy.shared.application(app, continue: userActivity, restorationHandler: restorationHandler)
}
func application(_: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
- Appsflyer.shared.application(didReceiveRemoteNotification: userInfo)
+ AppsFlyerLib.shared().handlePushNotification(userInfo)
}
func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
- Appsflyer.shared.application(didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
+ AppsFlyerLib.shared().registerUninstall(deviceToken)
NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
}
- Added full support for Capacitor 3 and removed compatibility with Capacitor 2
// TODO docs