Skip to content

Commit 2f35638

Browse files
authored
Merge pull request #116 from AppsFlyerSDK/dev/strictMode&waitForAttStatus
Strict mode+wait for att status API
2 parents ce196e4 + 3285531 commit 2f35638

File tree

6 files changed

+119
-16
lines changed

6 files changed

+119
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Versions
22

3+
## 6.2.4-nullsafety.5
4+
- Added support for strict mode (kids app)
5+
- Added support for wait for att status API
6+
37
## 6.2.4+4-nullsafety
48
- Fix small bug with validateAndLogInAppIosPurchase API
59

README.md

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ When submitting an issue please specify your AppsFlyer sign-up (account) email ,
2323
- [Getting started](#getting-started)
2424
- [Setting AppsFlyer options](#appsFlyer-options)
2525
- [Initializing the SDK](#init-sdk)
26-
- [Guides](#guides)
27-
- [API](#api)
26+
- [Set plugin for IOS 14](#ios14)
27+
- [Setting strict mode (app for kids)](#strictMode)
28+
- [Additional Guides](#guides)
29+
- [APIs](#api)
30+
31+
---
2832

2933
### Supported Platforms
3034

@@ -42,6 +46,7 @@ When submitting an issue please specify your AppsFlyer sign-up (account) email ,
4246
### The version `6.2.4-flutterv1` will use iOS SDK V6.2.4 with Flutter V1
4347

4448
---
49+
4550
## <a id="v6-breaking-changes"> **❗Migration Guide to v6**
4651
- [Integration guide](https://support.appsflyer.com//hc/en-us/articles/207032066#introduction)
4752
- [Migration guide](https://support.appsflyer.com/hc/en-us/articles/360011571778)
@@ -61,10 +66,14 @@ In v6 of AppsFlyer SDK there are some api breaking changes:
6166
### Important notice
6267
- Switch `ConversionData` and `OnAppOpenAttribution` to be based on callbacks instead of streams since plugin version `6.0.5+2`
6368

69+
---
70+
6471
## <a id="getting-started"> **📲 Getting started**
6572

6673
In order to install the plugin, visit [this](https://pub.dartlang.org/packages/appsflyer_sdk#-installing-tab-) page.
6774

75+
---
76+
6877
### <a id="appsFlyer-options"> ⚙️ AppsFlyerOptions
6978

7079
To start using AppsFlyer you first need to create an instance of `AppsflyerSdk` before using any other of our sdk functionalities.
@@ -83,6 +92,8 @@ Map appsFlyerOptions = { "afDevKey": afDevKey,
8392
AppsflyerSdk appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
8493
```
8594

95+
---
96+
8697
### <a id="init-sdk"> 🚀 Initializing the SDK
8798

8899
The next step is to call `initSdk` which have the optional boolean parameters
@@ -102,10 +113,77 @@ appsflyerSdk.initSdk(
102113
);
103114
```
104115

105-
## <a id="guides"> **📖 Guides**
116+
---
117+
118+
## <a id="ios14"> Set plugin for IOS 14
119+
120+
1. Add `#import <AppTrackingTransparency/AppTrackingTransparency.h>` in your `AppDelegate.m`
121+
122+
2. Add the ATT pop-up for IDFA collection so your `AppDelegate.m` will look like this:
123+
```
124+
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
125+
{
126+
self.viewController = [[MainViewController alloc] init];
127+
if (@available(iOS 14, *)) {
128+
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
129+
//If you want to do something with the pop-up
130+
}];
131+
}
132+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
133+
}
134+
```
135+
136+
3. Add Privacy - Tracking Usage Description inside your `.plist` file in Xcode.
137+
138+
4. Optional: Set the `timeToWaitForATTUserAuthorization` property in the `AppsFlyerOptions` to delay the sdk initazliation for a number of `x seconds` until the user accept the consent dialog:
139+
```dart
140+
AppsFlyerOptions options = AppsFlyerOptions(
141+
afDevKey: DotEnv().env["DEV_KEY"],
142+
appId: DotEnv().env["APP_ID"],
143+
showDebug: true,
144+
timeToWaitForATTUserAuthorization: 30
145+
);
146+
```
147+
148+
For more info visit our Full Support guide for iOS 14:
149+
150+
https://support.appsflyer.com/hc/en-us/articles/207032066#integration-33-configuring-app-tracking-transparency-att-support
151+
152+
---
153+
154+
## <a id="strictMode">👨‍👩‍👧‍👦 Strict mode for App-kids
155+
156+
Starting from version **6.2.4-nullsafety.5** iOS SDK comes in two variants: **Strict** mode and **Regular** mode.
157+
158+
Please read more: https://support.appsflyer.com/hc/en-us/articles/207032066#integration-strict-mode-sdk
159+
160+
***Change to Strict mode***
161+
162+
After you [installed](#installation) the AppsFlyer plugin:
163+
164+
1. Go to the `ios` folder
165+
2. Open `appsflyer_sdk.podspec` and add `/Strict` to the `s.ios.dependency` as follow:
166+
167+
`s.ios.dependency 'AppsFlyerFramework', '6.x.x'` To >> `s.ios.dependency 'AppsFlyerFramework/Strict', '6.x.x'`
168+
169+
3. Go to `example/ios` and Run `pod install`
170+
171+
***Change to Regular mode***
172+
173+
1. Go to the `ios` folder:
174+
2. Open `appsflyer_sdk.podspec` and remove `/strict`:
175+
176+
`s.ios.dependency 'AppsFlyerFramework/Strict', '6.x.x'` To >> `s.ios.dependency 'AppsFlyerFramework', '6.x.x'`
177+
178+
3. Go to `example/ios` and Run `pod install`
179+
180+
---
181+
182+
## <a id="guides"> **📖 Additional Guides (Deeplinking & more) **
106183

107184
Great installation and setup guides can be viewed [here](https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/Guides.md)
108185

186+
---
109187
## <a id="api"> **📑 API**
110188

111189
see the full [API](https://github.com/AppsFlyerSDK/appsflyer-flutter-plugin/blob/master/doc/API.md) available for this plugin.

doc/Guides.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To start using AppsFlyer you first need to create an instance of `AppsflyerSdk`
2626
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
2727
//..
2828
29-
Map appsFlyerOptions = { "afDevKey": afDevKey,
29+
AppsFlyerOptions appsFlyerOptions = { "afDevKey": afDevKey,
3030
"afAppId": appId,
3131
"isDebug": true};
3232
@@ -46,6 +46,7 @@ appsflyerSdk.initSdk(
4646
registerOnDeepLinkingCallback: true
4747
);
4848
```
49+
4950
---
5051

5152
## <a id="out-of-store"> Android Out of store

ios/Classes/AppsflyerSdkPlugin.m

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#import "AppsflyerSdkPlugin.h"
22
#import "AppsFlyerStreamHandler.h"
33
#import <objc/message.h>
4+
5+
46
typedef void (*bypassDidFinishLaunchingWithOption)(id, SEL, NSInteger);
7+
typedef void (*bypassDisableAdvertisingIdentifier)(id, SEL, BOOL);
8+
typedef void (*bypassWaitForATTUserAuthorization)(id, SEL, NSTimeInterval);
9+
510

611
@implementation AppsflyerSdkPlugin {
712
FlutterEventChannel *_eventChannel;
@@ -466,18 +471,32 @@ - (void)initSdkWithCall:(FlutterMethodCall*)call result:(FlutterResult)result{
466471

467472

468473
[AppsFlyerLib shared].disableCollectASA = disableCollectASA;
469-
[AppsFlyerLib shared].disableAdvertisingIdentifier = disableAdvertisingIdentifier;
474+
475+
SEL DisableAdvertisingSel = NSSelectorFromString(@"setDisableAdvertisingIdentifier:");
476+
id AppsFlyer = [AppsFlyerLib shared];
477+
if ([AppsFlyer respondsToSelector:DisableAdvertisingSel] && disableAdvertisingIdentifier) {
478+
bypassDisableAdvertisingIdentifier msgSend = (bypassDisableAdvertisingIdentifier)objc_msgSend;
479+
msgSend(AppsFlyer, DisableAdvertisingSel, disableAdvertisingIdentifier);
480+
}
481+
470482
[AppsFlyerLib shared].appleAppID = appId;
471483
[AppsFlyerLib shared].appsFlyerDevKey = devKey;
472484
[AppsFlyerLib shared].isDebug = isDebug;
473-
485+
474486
// Load SKAD rules
475487
SEL SKSel = NSSelectorFromString(@"__willResolveSKRules:");
476-
id AppsFlyer = [AppsFlyerLib shared];
488+
477489
if ([AppsFlyer respondsToSelector:SKSel]) {
478490
bypassDidFinishLaunchingWithOption msgSend = (bypassDidFinishLaunchingWithOption)objc_msgSend;
479491
msgSend(AppsFlyer, SKSel, 2);
480492
}
493+
494+
SEL WaitForATTSel = NSSelectorFromString(@"waitForATTUserAuthorizationWithTimeoutInterval:");
495+
496+
if ([AppsFlyer respondsToSelector:WaitForATTSel] && timeToWaitForATTUserAuthorization != 0) {
497+
bypassWaitForATTUserAuthorization msgSend = (bypassWaitForATTUserAuthorization)objc_msgSend;
498+
msgSend(AppsFlyer, WaitForATTSel, timeToWaitForATTUserAuthorization);
499+
}
481500

482501
[[AppsFlyerLib shared] start];
483502

lib/src/appsflyer_sdk.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ class AppsflyerSdk {
7171
}
7272

7373
if (Platform.isIOS) {
74+
if (options.timeToWaitForATTUserAuthorization != null) {
75+
dynamic timeToWaitForATTUserAuthorization = options.timeToWaitForATTUserAuthorization;
76+
assert(timeToWaitForATTUserAuthorization is double);
77+
78+
validatedOptions[AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION] = timeToWaitForATTUserAuthorization;
79+
}
7480
dynamic appID = options.appId;
7581
assert(appID != null, "appleAppId is required for iOS apps");
7682
assert(appID is String);
@@ -125,16 +131,11 @@ class AppsflyerSdk {
125131
}
126132

127133
if (Platform.isIOS) {
128-
if (options[
129-
AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION] !=
130-
null) {
131-
dynamic timeToWaitForATTUserAuthorization = options[
132-
AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION];
134+
if (options[AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION] != null) {
135+
dynamic timeToWaitForATTUserAuthorization = options[AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION];
133136
assert(timeToWaitForATTUserAuthorization is double);
134137

135-
afOptions[
136-
AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION] =
137-
timeToWaitForATTUserAuthorization;
138+
afOptions[AppsflyerConstants.AF_TIME_TO_WAIT_FOR_ATT_USER_AUTHORIZATION] = timeToWaitForATTUserAuthorization;
138139
}
139140

140141
dynamic appID = options[AppsflyerConstants.AF_APP_Id];

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: appsflyer_sdk
22
description: A Flutter plugin for AppsFlyer SDK. Supports iOS and Android.
3-
version: 6.2.4+4-nullsafety
3+
version: 6.2.4-nullsafety.5
44

55
homepage: https://github.com/AppsFlyerSDK/flutter_appsflyer_sdk
66

0 commit comments

Comments
 (0)