diff --git a/README.md b/README.md index 457f1f8..f7fdabe 100644 --- a/README.md +++ b/README.md @@ -159,15 +159,12 @@ appsflyerSdk.initSdk( 2. Add the ATT pop-up for IDFA collection so your `AppDelegate.m` will look like this: ``` --(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions -{ - [GeneratedPluginRegistrant registerWithRegistry:self]; +- (void)applicationDidBecomeActive:(nonnull UIApplication *)application { if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { - //If you want to do something with the pop-up + // native code here }]; } - return [super application:application didFinishLaunchingWithOptions:launchOptions]; } ``` diff --git a/android/build.gradle b/android/build.gradle index 247b3d9..473e683 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -35,6 +35,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.0' - implementation 'com.appsflyer:af-android-sdk:6.4.3' + implementation 'com.appsflyer:af-android-sdk:6.5.2' implementation 'com.android.installreferrer:installreferrer:2.1' } \ No newline at end of file diff --git a/android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java b/android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java index 284b3f9..de77954 100644 --- a/android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java +++ b/android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java @@ -313,7 +313,7 @@ private void setSharingFilterForPartners(MethodCall call, Result result) { } private void setDisableAdvertisingIdentifiers(MethodCall call, Result result) { - isSetDisableAdvertisingIdentifiersEnable = (boolean) call.argument("isSetDisableAdvertisingIdentifiersEnable"); + isSetDisableAdvertisingIdentifiersEnable = (boolean) call.arguments; if (isSetDisableAdvertisingIdentifiersEnable) { AppsFlyerLib.getInstance().setDisableAdvertisingIdentifiers(true); } else { diff --git a/doc/API.md b/doc/API.md index 5fa27fe..a29cda3 100644 --- a/doc/API.md +++ b/doc/API.md @@ -39,6 +39,8 @@ - [setCurrentDeviceLanguage](#setCurrentDeviceLanguage) - [setSharingFilterForPartners](#setSharingFilterForPartners) - [setOneLinkCustomDomain](#setOneLinkCustomDomain) +- [setDisableAdvertisingIdentifiers](#setDisableAdvertisingIdentifiers) + --- ##### **`AppsflyerSdk(Map options)`** @@ -516,4 +518,13 @@ _Example:_ ```dart appsFlyerSdk.setOneLinkCustomDomain(["promotion.greatapp.com","click.greatapp.com","deals.greatapp.com"]); ``` +--- +** `void setDisableAdvertisingIdentifiers(bool isSetDisableAdvertisingIdentifiersEnable)`** + +Manually enable or disable Advertiser ID in Android & IDFA in iOS + +_Example:_ +```dart +widget.appsFlyerSdk.setDisableAdvertisingIdentifiers(true); +``` --- \ No newline at end of file diff --git a/doc/Guides.md b/doc/Guides.md index b6a995a..b1fdb9e 100644 --- a/doc/Guides.md +++ b/doc/Guides.md @@ -435,19 +435,15 @@ Or - Add the ATT pop-up for IDFA collection so your `AppDelegate.m` will look like this: - - ``` - -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions - { - [GeneratedPluginRegistrant registerWithRegistry:self]; - if (@available(iOS 14, *)) { - [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { - //If you want to do something with the pop-up - }]; - } - return [super application:application didFinishLaunchingWithOptions:launchOptions]; - } - ``` +``` +- (void)applicationDidBecomeActive:(nonnull UIApplication *)application { + if (@available(iOS 14, *)) { + [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { + // native code here + }]; + } +} +``` diff --git a/example/android/.project b/example/android/.project index 3964dd3..4ac772e 100644 --- a/example/android/.project +++ b/example/android/.project @@ -14,4 +14,15 @@ org.eclipse.buildship.core.gradleprojectnature + + + 1643725221956 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/example/android/app/.project b/example/android/app/.project index ac485d7..453e11a 100644 --- a/example/android/app/.project +++ b/example/android/app/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.buildship.core.gradleprojectnature + + + 1643725221965 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 653540d..1b819ba 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -7,12 +7,15 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GeneratedPluginRegistrant registerWithRegistry:self]; - if (@available(iOS 14, *)) { + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +- (void)applicationDidBecomeActive:(nonnull UIApplication *)application { + if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { - //If you want to do something with the pop-up + // native code here }]; } - return [super application:application didFinishLaunchingWithOptions:launchOptions]; } // Reports app open from a Universal Link for iOS 9 or above diff --git a/example/lib/main_page.dart b/example/lib/main_page.dart index 0474b1c..b936f58 100644 --- a/example/lib/main_page.dart +++ b/example/lib/main_page.dart @@ -24,7 +24,7 @@ class MainPageState extends State { afDevKey: DotEnv().env["DEV_KEY"], appId: DotEnv().env["APP_ID"], showDebug: true, - disableAdvertisingIdentifier: true + timeToWaitForATTUserAuthorization: 15 ); _appsflyerSdk = AppsflyerSdk(options); _appsflyerSdk.onAppOpenAttribution((res) { @@ -60,6 +60,7 @@ class MainPageState extends State { _deepLinkData = dp.toJson(); }); }); + } @override @@ -100,7 +101,6 @@ class MainPageState extends State { } Future logEvent(String eventName, Map eventValues) { - _appsflyerSdk.disableSKAdNetwork(false); return _appsflyerSdk.logEvent(eventName, eventValues); } diff --git a/ios/Classes/AppsflyerSdkPlugin.m b/ios/Classes/AppsflyerSdkPlugin.m index 6780a6c..550cc7e 100644 --- a/ios/Classes/AppsflyerSdkPlugin.m +++ b/ios/Classes/AppsflyerSdkPlugin.m @@ -131,12 +131,23 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { [self setCurrentDeviceLanguage:call result:result]; }else if([@"setSharingFilterForPartners" isEqualToString:call.method]){ [self setSharingFilterForPartners:call result:result]; + }else if([@"setDisableAdvertisingIdentifiers" isEqualToString:call.method]){ + [self setDisableAdvertisingIdentifiers:call result:result]; } else{ result(FlutterMethodNotImplemented); } } +- (void)setDisableAdvertisingIdentifiers:(FlutterMethodCall*)call result:(FlutterResult)result{ + id isAdvertiserIdEnabled = call.arguments; + if ([isAdvertiserIdEnabled isKindOfClass:[NSNumber class]]) { + BOOL _isAdvertiserIdEnabled = [isAdvertiserIdEnabled boolValue]; + [[AppsFlyerLib shared] setDisableAdvertisingIdentifier: _isAdvertiserIdEnabled]; + } + result(nil); +} + - (void)setSharingFilterForPartners:(FlutterMethodCall*)call result:(FlutterResult)result{ NSArray* partners = call.arguments; [[AppsFlyerLib shared] setSharingFilterForPartners: partners]; diff --git a/ios/appsflyer_sdk.podspec b/ios/appsflyer_sdk.podspec index 1c20e94..1d57c7f 100644 --- a/ios/appsflyer_sdk.podspec +++ b/ios/appsflyer_sdk.podspec @@ -21,6 +21,6 @@ AppsFlyer is the market leader in mobile advertising attribution & analytics, he s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.ios.dependency 'AppsFlyerFramework', '6.4.4' + s.ios.dependency 'AppsFlyerFramework', '6.5.2' end diff --git a/lib/src/appsflyer_sdk.dart b/lib/src/appsflyer_sdk.dart index b691ad9..f76a083 100644 --- a/lib/src/appsflyer_sdk.dart +++ b/lib/src/appsflyer_sdk.dart @@ -395,7 +395,7 @@ class AppsflyerSdk { } void setDisableAdvertisingIdentifiers(bool isEnabled) { - _methodChannel.invokeMethod("setDisableAdvertisingIdentifiers", { 'isSetDisableAdvertisingIdentifiersEnable': isEnabled }); + _methodChannel.invokeMethod("setDisableAdvertisingIdentifiers", isEnabled); } void onInstallConversionData(Function callback) async { startListening(callback as void Function(dynamic), "onInstallConversionData");