Skip to content

Commit

Permalink
SKAd fix + disable SKAd API
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Sokolov committed Mar 24, 2021
1 parent 5a9ddca commit 588f02f
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Supported platforms:

Based on:

- iOS AppsFlyerSDK **v6.2.3**
- iOS AppsFlyerSDK **v6.2.4**
- Android AppsFlyerSDK **v6.2.3**

Built with:
Expand Down
3 changes: 3 additions & 0 deletions actionscript/default/src/AppsFlyerInterface.as
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class AppsFlyerInterface extends EventDispatcher {
public function waitForATTUserAuthorization():void {
}

public function disableSKAdNetwork(shouldDisable:Boolean):void {
}

// public function requestATTPermission():void{
// }

Expand Down
4 changes: 4 additions & 0 deletions actionscript/mobile/src/AppsFlyerInterface.as
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public class AppsFlyerInterface extends EventDispatcher {
context.call("waitForATTUserAuthorization", timeout);
}

public function disableSKAdNetwork(shouldDisable:Boolean):void {
context.call("disableSKAdNetwork", shouldDisable);
}

// public function requestATTPermission():void{
// context.call("requestATTPermission");
// }
Expand Down
1 change: 1 addition & 0 deletions android/src/com/appsflyer/adobeair/AppsFlyerContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Map<String, FREFunction> getFunctions() {
map.put("setCustomerUserId", new SetCustomerUserId());
map.put("setUserEmails", new SetUserEmails());
map.put("waitForATTUserAuthorization", new waitForATTUserAuthorization());
map.put("disableSKAdNetwork", new disableSKAdNetwork());
return map;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.appsflyer.adobeair.functions;

import android.util.Log;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;

public class disableSKAdNetwork implements FREFunction {


private final static String LOG = "AppsFlyer";

@Override
public FREObject call(FREContext freContext, FREObject[] freObjects) {
Log.d(LOG, "disableSKAdNetwork method is not supported on Android");
return null;
}
}
Binary file modified bin/AppsFlyerAIRExtension-strict.ane
Binary file not shown.
Binary file modified bin/AppsFlyerAIRExtension-witout-gp-support.ane
Binary file not shown.
Binary file modified bin/AppsFlyerAIRExtension-witout-gp.ane
Binary file not shown.
Binary file modified bin/AppsFlyerAIRExtension.ane
Binary file not shown.
Binary file modified bin/AppsFlyerAIRExtension.swc
Binary file not shown.
2 changes: 1 addition & 1 deletion build/extension.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<extension xmlns="http://ns.adobe.com/air/extension/33.1">
<id>com.appsflyer.adobeair</id>
<versionNumber>6.2.31</versionNumber>
<versionNumber>6.2.41</versionNumber>
<platforms>
<platform name="Android-ARM">
<applicationDeployment>
Expand Down
30 changes: 29 additions & 1 deletion ios/AppsFlyerAIRExtension/AppsFlyerAIRExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#define DEFINE_ANE_FUNCTION(fn) FREObject (fn)(FREContext context, void* functionData, uint32_t argc, FREObject argv[])

typedef void (*bypassDidFinishLaunchingWithOption)(id, SEL, NSInteger);

@implementation AppsFlyerAIRExtension

static IMP __original_applicationDidBecomeActive_Imp;
Expand Down Expand Up @@ -51,6 +53,18 @@ BOOL didReceiveRemoteNotificationHandler(id self, SEL _cmd, UIApplication* appli
return ((BOOL(*)(id, SEL, UIApplication*, NSDictionary*))__original_didReceiveRemoteNotification_Imp)(self, _cmd, application, userInfo);
}

static IMP __original_didFinishLaunchingWithOptions_Imp;
BOOL didFinishLaunchingWithOptions(id self, SEL _cmd, UIApplication* application, NSDictionary<UIApplicationLaunchOptionsKey,id> * launchOptions) {
NSLog(@"[AppsFlyerAIRExtension] didFinishLaunchingWithOptions: %@", self);
SEL SKSel = NSSelectorFromString(@"__willResolveSKRules:");
id AppsFlyer = [AppsFlyerLib shared];
if ([AppsFlyer respondsToSelector:SKSel]) {
bypassDidFinishLaunchingWithOption msgSend = (bypassDidFinishLaunchingWithOption)objc_msgSend;
msgSend(AppsFlyer, SKSel, 2);
}
return ((BOOL(*)(id, SEL, UIApplication*, NSDictionary<UIApplicationLaunchOptionsKey,id> *))__original_didFinishLaunchingWithOptions_Imp)(self, _cmd, application, launchOptions);
}

+ (void) load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand All @@ -64,18 +78,21 @@ + (void) load {
SEL originalOpenURLDeprecatedSelector = @selector(application:openURL:sourceApplication:annotation:);
SEL originalOpenURLSelector = @selector(application:openURL:options:);
SEL originalDidReceiveRemoteNotificationSelector = @selector(application:didReceiveRemoteNotification:);
SEL originalDidFinishLaunchingWithOptionsSelector = @selector(application:didFinishLaunchingWithOptions:);

Method originalApplicationDidBecomeActiveMethod = class_getInstanceMethod(objectClass, originalApplicationDidBecomeActiveSelector);
Method originalContinueUserActivityMethod = class_getInstanceMethod(objectClass, originalContinueUserActivitySelector);
Method originalOpenURLDeprecatedMethod = class_getInstanceMethod(objectClass, originalOpenURLDeprecatedSelector);
Method originalOpenURLMethod = class_getInstanceMethod(objectClass, originalOpenURLSelector);
Method originalDidReceiveRemoteNotificationMethod = class_getInstanceMethod(objectClass, originalDidReceiveRemoteNotificationSelector);
Method originalDidFinishLaunchingWithOptionsMethod = class_getInstanceMethod(objectClass, originalDidFinishLaunchingWithOptionsSelector);

__original_applicationDidBecomeActive_Imp = method_setImplementation(originalApplicationDidBecomeActiveMethod, (IMP)applicationDidBecomeActive);
__original_continueUserActivity_Imp = method_setImplementation(originalContinueUserActivityMethod, (IMP)continueUserActivity);
__original_openURLDeprecated_Imp = method_setImplementation(originalOpenURLDeprecatedMethod, (IMP)openURLDeprecated);
__original_openURL_Imp = method_setImplementation(originalOpenURLMethod, (IMP)openURL);
__original_didReceiveRemoteNotification_Imp = method_setImplementation(originalDidReceiveRemoteNotificationMethod, (IMP)didReceiveRemoteNotificationHandler);
__original_didFinishLaunchingWithOptions_Imp = method_setImplementation(originalDidFinishLaunchingWithOptionsMethod, (IMP)didFinishLaunchingWithOptions);
}
});
}
Expand Down Expand Up @@ -427,7 +444,14 @@ + (NSData *)dataFromHexString:(NSString *)string
double timeoutInterval = (double)interval;
[[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:timeoutInterval];
}
return NULL;
}

DEFINE_ANE_FUNCTION(disableSKAdNetwork)
{
uint32_t value;
FREGetObjectAsBool(argv[0], &value);
[AppsFlyerLib shared].disableSKAdNetwork = value;
return NULL;
}

Expand All @@ -442,7 +466,7 @@ + (NSData *)dataFromHexString:(NSString *)string

void AFExtContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet)
{
*numFunctionsToTest = 28;
*numFunctionsToTest = 29;
FRENamedFunction* func = (FRENamedFunction*)malloc(sizeof(FRENamedFunction) * *numFunctionsToTest);

func[19].name = (const uint8_t*)"init";
Expand Down Expand Up @@ -481,6 +505,10 @@ void AFExtContextInitializer(void* extData, const uint8_t* ctxType, FREContext c
func[27].functionData = NULL;
func[27].function = &setSharingFilter;

func[28].name = (const uint8_t*)"disableSKAdNetwork";
func[28].functionData = NULL;
func[28].function = &disableSKAdNetwork;

func[0].name = (const uint8_t*)"start";
func[0].functionData = NULL;
func[0].function = &start;
Expand Down

0 comments on commit 588f02f

Please sign in to comment.