bingo 项目提交
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// AFUnityUtils.h
|
||||
//
|
||||
// Created by Andrii H. and Dmitry O. on 16 Oct 2023
|
||||
//
|
||||
|
||||
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||
#else
|
||||
#import "AppsFlyerLib.h"
|
||||
#endif
|
||||
|
||||
static NSString* stringFromChar(const char *str);
|
||||
static NSDictionary* dictionaryFromJson(const char *jsonString);
|
||||
static const char* stringFromdictionary(NSDictionary* dictionary);
|
||||
static NSArray<NSString*> *NSArrayFromCArray(int length, const char **arr);
|
||||
static char* getCString(const char* string);
|
||||
static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator);
|
||||
static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt);
|
||||
static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult);
|
||||
static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b0609ff467554f2088aee1c52bf54a2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,145 @@
|
||||
//
|
||||
// AFUnityUtils.mm
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by Jonathan Wesfield on 24/07/2019.
|
||||
//
|
||||
|
||||
#import "AFUnityUtils.h"
|
||||
|
||||
static NSString* stringFromChar(const char *str) {
|
||||
return str ? [NSString stringWithUTF8String:str] : nil;
|
||||
}
|
||||
|
||||
static NSDictionary* dictionaryFromJson(const char *jsonString) {
|
||||
if(jsonString){
|
||||
NSData *jsonData = [[NSData alloc] initWithBytes:jsonString length:strlen(jsonString)];
|
||||
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil];
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
static const char* stringFromdictionary(NSDictionary* dictionary) {
|
||||
if(dictionary){
|
||||
NSError * err;
|
||||
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&err];
|
||||
NSString * myString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
return [myString UTF8String];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
static NSDictionary* dictionaryFromNSError(NSError* error) {
|
||||
if(error){
|
||||
NSInteger code = [error code];
|
||||
NSString *localizedDescription = [error localizedDescription];
|
||||
|
||||
NSDictionary *errorDictionary = @{
|
||||
@"code" : @(code) ?: @(-1),
|
||||
@"localizedDescription" : localizedDescription,
|
||||
};
|
||||
return errorDictionary;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
static NSArray<NSString*> *NSArrayFromCArray(int length, const char **arr) {
|
||||
NSMutableArray<NSString *> *res = [[NSMutableArray alloc] init];
|
||||
for(int i = 0; i < length; i++) {
|
||||
if (arr[i]) {
|
||||
[res addObject:[NSString stringWithUTF8String:arr[i]]];
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static char* getCString(const char* string){
|
||||
if (string == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* res = (char*)malloc(strlen(string) + 1);
|
||||
strcpy(res, string);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator) {
|
||||
|
||||
NSArray* generatorKeys = @[@"channel", @"customerID", @"campaign", @"referrerName", @"referrerImageUrl", @"deeplinkPath", @"baseDeeplink", @"brandDomain"];
|
||||
|
||||
NSMutableDictionary* mutableDictionary = [dictionary mutableCopy];
|
||||
|
||||
[generator setChannel:[dictionary objectForKey: @"channel"]];
|
||||
[generator setReferrerCustomerId:[dictionary objectForKey: @"customerID"]];
|
||||
[generator setCampaign:[dictionary objectForKey: @"campaign"]];
|
||||
[generator setReferrerName:[dictionary objectForKey: @"referrerName"]];
|
||||
[generator setReferrerImageURL:[dictionary objectForKey: @"referrerImageUrl"]];
|
||||
[generator setDeeplinkPath:[dictionary objectForKey: @"deeplinkPath"]];
|
||||
[generator setBaseDeeplink:[dictionary objectForKey: @"baseDeeplink"]];
|
||||
[generator setBrandDomain:[dictionary objectForKey: @"brandDomain"]];
|
||||
|
||||
|
||||
[mutableDictionary removeObjectsForKeys:generatorKeys];
|
||||
|
||||
[generator addParameters:mutableDictionary];
|
||||
|
||||
return generator;
|
||||
}
|
||||
|
||||
static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt){
|
||||
|
||||
EmailCryptType emailCryptType;
|
||||
switch (emailCryptTypeInt){
|
||||
case 1:
|
||||
emailCryptType = EmailCryptTypeSHA256;
|
||||
break;
|
||||
default:
|
||||
emailCryptType = EmailCryptTypeNone;
|
||||
break;
|
||||
}
|
||||
|
||||
return emailCryptType;
|
||||
}
|
||||
|
||||
static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult){
|
||||
NSString* result;
|
||||
switch (deepLinkResult){
|
||||
case AFSDKDeepLinkResultStatusFound:
|
||||
result = @"FOUND";
|
||||
break;
|
||||
case AFSDKDeepLinkResultStatusFailure:
|
||||
result = @"ERROR";
|
||||
break;
|
||||
case AFSDKDeepLinkResultStatusNotFound:
|
||||
result = @"NOT_FOUND";
|
||||
break;
|
||||
default:
|
||||
result = @"ERROR";
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result){
|
||||
NSString* res;
|
||||
|
||||
if (result && result.error){
|
||||
if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1001) {
|
||||
res = @"TIMEOUT";
|
||||
} else if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1009) {
|
||||
res = @"NETWORK";
|
||||
}
|
||||
}
|
||||
|
||||
res = @"UNKNOWN";
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18a03931864e84d86bedcc99c440e060
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// AppsFlyer+AppController.m
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by Jonathan Wesfield on 24/07/2019.
|
||||
//
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#import "UnityAppController.h"
|
||||
#import "AppsFlyeriOSWrapper.h"
|
||||
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||
#else
|
||||
#import "AppsFlyerLib.h"
|
||||
#endif
|
||||
|
||||
|
||||
@implementation UnityAppController (AppsFlyerSwizzledAppController)
|
||||
|
||||
static BOOL didEnteredBackGround __unused;
|
||||
static IMP __original_applicationDidBecomeActive_Imp __unused;
|
||||
static IMP __original_applicationDidEnterBackground_Imp __unused;
|
||||
static IMP __original_didReceiveRemoteNotification_Imp __unused;
|
||||
static IMP __original_continueUserActivity_Imp __unused;
|
||||
static IMP __original_openUrl_Imp __unused;
|
||||
|
||||
|
||||
+ (void)load {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
#if !AFSDK_SHOULD_SWIZZLE
|
||||
|
||||
id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"];
|
||||
BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO;
|
||||
|
||||
if(shouldSwizzle){
|
||||
|
||||
Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:));
|
||||
__original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive);
|
||||
|
||||
Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:));
|
||||
__original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground);
|
||||
|
||||
|
||||
Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:));
|
||||
__original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification);
|
||||
|
||||
|
||||
Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:));
|
||||
__original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL);
|
||||
|
||||
if (_AppsFlyerdelegate == nil) {
|
||||
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||
}
|
||||
|
||||
[self swizzleContinueUserActivity:[self class]];
|
||||
}
|
||||
#elif AFSDK_SHOULD_SWIZZLE
|
||||
Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:));
|
||||
__original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive);
|
||||
|
||||
Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:));
|
||||
__original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground);
|
||||
|
||||
|
||||
Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:));
|
||||
__original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification);
|
||||
|
||||
|
||||
Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:));
|
||||
__original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL);
|
||||
|
||||
if (_AppsFlyerdelegate == nil) {
|
||||
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||
}
|
||||
|
||||
[self swizzleContinueUserActivity:[self class]];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
+(void)swizzleContinueUserActivity:(Class)class {
|
||||
|
||||
SEL originalSelector = @selector(application:continueUserActivity:restorationHandler:);
|
||||
|
||||
Method defaultMethod = class_getInstanceMethod(class, originalSelector);
|
||||
Method swizzledMethod = class_getInstanceMethod(class, @selector(__swizzled_continueUserActivity));
|
||||
|
||||
BOOL isMethodExists = !class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
|
||||
|
||||
if (isMethodExists) {
|
||||
__original_continueUserActivity_Imp = method_setImplementation(defaultMethod, (IMP)__swizzled_continueUserActivity);
|
||||
} else {
|
||||
class_replaceMethod(class, originalSelector, (IMP)__swizzled_continueUserActivity, method_getTypeEncoding(swizzledMethod));
|
||||
}
|
||||
}
|
||||
|
||||
BOOL __swizzled_continueUserActivity(id self, SEL _cmd, UIApplication* application, NSUserActivity* userActivity, void (^restorationHandler)(NSArray*)) {
|
||||
NSLog(@"swizzled continueUserActivity");
|
||||
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||
|
||||
if(__original_continueUserActivity_Imp){
|
||||
return ((BOOL(*)(id, SEL, UIApplication*, NSUserActivity*, void (^)(NSArray*)))__original_continueUserActivity_Imp)(self, _cmd, application, userActivity, NULL);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void __swizzled_applicationDidBecomeActive(id self, SEL _cmd, UIApplication* launchOptions) {
|
||||
NSLog(@"swizzled applicationDidBecomeActive");
|
||||
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||
|
||||
if(didEnteredBackGround && AppsFlyeriOSWarpper.didCallStart == YES){
|
||||
[[AppsFlyerLib shared] start];
|
||||
}
|
||||
|
||||
if(__original_applicationDidBecomeActive_Imp){
|
||||
((void(*)(id,SEL, UIApplication*))__original_applicationDidBecomeActive_Imp)(self, _cmd, launchOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void __swizzled_applicationDidEnterBackground(id self, SEL _cmd, UIApplication* application) {
|
||||
NSLog(@"swizzled applicationDidEnterBackground");
|
||||
didEnteredBackGround = YES;
|
||||
if(__original_applicationDidEnterBackground_Imp){
|
||||
((void(*)(id,SEL, UIApplication*))__original_applicationDidEnterBackground_Imp)(self, _cmd, application);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL __swizzled_didReceiveRemoteNotification(id self, SEL _cmd, UIApplication* application, NSDictionary* userInfo,void (^UIBackgroundFetchResult)(void) ) {
|
||||
NSLog(@"swizzled didReceiveRemoteNotification");
|
||||
|
||||
[[AppsFlyerLib shared] handlePushNotification:userInfo];
|
||||
|
||||
if(__original_didReceiveRemoteNotification_Imp){
|
||||
return ((BOOL(*)(id, SEL, UIApplication*, NSDictionary*, int(UIBackgroundFetchResult)))__original_didReceiveRemoteNotification_Imp)(self, _cmd, application, userInfo, nil);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL __swizzled_openURL(id self, SEL _cmd, UIApplication* application, NSURL* url, NSDictionary * options) {
|
||||
NSLog(@"swizzled openURL");
|
||||
[[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
|
||||
if(__original_openUrl_Imp){
|
||||
return ((BOOL(*)(id, SEL, UIApplication*, NSURL*, NSDictionary*))__original_openUrl_Imp)(self, _cmd, application, url, options);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ae9e1f7daef2427588fab2fbf8d35d5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// AppsFlyerAppController.mm
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by Jonathan Wesfield on 30/07/2019.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "UnityAppController.h"
|
||||
#import "AppDelegateListener.h"
|
||||
#import "AppsFlyeriOSWrapper.h"
|
||||
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||
#else
|
||||
#import "AppsFlyerLib.h"
|
||||
#endif
|
||||
#import <objc/message.h>
|
||||
|
||||
/**
|
||||
Note if you would like to use method swizzeling see AppsFlyer+AppController.m
|
||||
If you are using swizzeling then comment out the method that is being swizzeled in AppsFlyerAppController.mm
|
||||
Only use swizzeling if there are conflicts with other plugins that needs to be resolved.
|
||||
*/
|
||||
|
||||
|
||||
@interface AppsFlyerAppController : UnityAppController <AppDelegateListener>
|
||||
{
|
||||
BOOL didEnteredBackGround;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation AppsFlyerAppController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"];
|
||||
BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO;
|
||||
|
||||
if(!shouldSwizzle){
|
||||
UnityRegisterAppDelegateListener(self);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didFinishLaunching:(NSNotification*)notification {
|
||||
NSLog(@"got didFinishLaunching = %@",notification.userInfo);
|
||||
|
||||
|
||||
if (_AppsFlyerdelegate == nil) {
|
||||
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||
}
|
||||
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||
|
||||
if (notification.userInfo[@"url"]) {
|
||||
[self onOpenURL:notification];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)didBecomeActive:(NSNotification*)notification {
|
||||
NSLog(@"got didBecomeActive(out) = %@", notification.userInfo);
|
||||
if (didEnteredBackGround == YES && AppsFlyeriOSWarpper.didCallStart == YES) {
|
||||
[[AppsFlyerLib shared] start];
|
||||
didEnteredBackGround = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didEnterBackground:(NSNotification*)notification {
|
||||
NSLog(@"got didEnterBackground = %@", notification.userInfo);
|
||||
didEnteredBackGround = YES;
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
|
||||
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)onOpenURL:(NSNotification*)notification {
|
||||
NSLog(@"got onOpenURL = %@", notification.userInfo);
|
||||
NSURL *url = notification.userInfo[@"url"];
|
||||
NSString *sourceApplication = notification.userInfo[@"sourceApplication"];
|
||||
|
||||
if (sourceApplication == nil) {
|
||||
sourceApplication = @"";
|
||||
}
|
||||
|
||||
if (url != nil) {
|
||||
[[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:nil];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveRemoteNotification:(NSNotification*)notification {
|
||||
NSLog(@"got didReceiveRemoteNotification = %@", notification.userInfo);
|
||||
[[AppsFlyerLib shared] handlePushNotification:notification.userInfo];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#if !(AFSDK_SHOULD_SWIZZLE)
|
||||
|
||||
IMPL_APP_CONTROLLER_SUBCLASS(AppsFlyerAppController)
|
||||
|
||||
#endif
|
||||
/**
|
||||
Note if you would not like to use IMPL_APP_CONTROLLER_SUBCLASS you can replace it with the code below.
|
||||
<code>
|
||||
+(void)load
|
||||
{
|
||||
[AppsFlyerAppController plugin];
|
||||
}
|
||||
|
||||
// Singleton accessor.
|
||||
+ (AppsFlyerAppController *)plugin
|
||||
{
|
||||
static AppsFlyerAppController *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
sharedInstance = [[AppsFlyerAppController alloc] init];
|
||||
});
|
||||
|
||||
return sharedInstance;
|
||||
}
|
||||
</code>
|
||||
**/
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d1497a1493b24fecaa58bd3a7b707f9
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// AppsFlyerAttribution.h
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by Margot Guetta on 11/04/2021.
|
||||
//
|
||||
|
||||
#ifndef AppsFlyerAttribution_h
|
||||
#define AppsFlyerAttribution_h
|
||||
#endif /* AppsFlyerAttribution_h */
|
||||
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||
#else
|
||||
#import "AppsFlyerLib.h"
|
||||
#endif
|
||||
|
||||
|
||||
@interface AppsFlyerAttribution : NSObject
|
||||
@property NSUserActivity*_Nullable userActivity;
|
||||
@property (nonatomic, copy) void (^ _Nullable restorationHandler)(NSArray *_Nullable );
|
||||
@property NSURL * _Nullable url;
|
||||
@property NSDictionary * _Nullable options;
|
||||
@property NSString* _Nullable sourceApplication;
|
||||
@property id _Nullable annotation;
|
||||
@property BOOL isBridgeReady;
|
||||
|
||||
+ (AppsFlyerAttribution *_Nullable)shared;
|
||||
- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler;
|
||||
- (void) handleOpenUrl:(NSURL*_Nullable)url options:(NSDictionary*_Nullable) options;
|
||||
- (void) handleOpenUrl: (NSURL *_Nonnull)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation;
|
||||
|
||||
@end
|
||||
|
||||
static NSString * _Nullable const AF_BRIDGE_SET = @"bridge is set";
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8544dc3b3c7bb40d397b2de568df1058
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// NSObject+AppsFlyerAttribution.m
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by Margot Guetta on 11/04/2021.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AppsFlyerAttribution.h"
|
||||
|
||||
@implementation AppsFlyerAttribution
|
||||
|
||||
+ (id)shared {
|
||||
static AppsFlyerAttribution *shared = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
shared = [[self alloc] init];
|
||||
});
|
||||
return shared;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
if (self = [super init]) {
|
||||
self.options = nil;
|
||||
self.restorationHandler = nil;
|
||||
self.url = nil;
|
||||
self.userActivity = nil;
|
||||
self.annotation = nil;
|
||||
self.sourceApplication = nil;
|
||||
self.isBridgeReady = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(receiveBridgeReadyNotification:)
|
||||
name:AF_BRIDGE_SET
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler{
|
||||
if(self.isBridgeReady == YES){
|
||||
[[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||
}else{
|
||||
[AppsFlyerAttribution shared].userActivity = userActivity;
|
||||
[AppsFlyerAttribution shared].restorationHandler = restorationHandler;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) handleOpenUrl:(NSURL *)url options:(NSDictionary *)options{
|
||||
if(self.isBridgeReady == YES){
|
||||
[[AppsFlyerLib shared] handleOpenUrl:url options:options];
|
||||
}else{
|
||||
[AppsFlyerAttribution shared].url = url;
|
||||
[AppsFlyerAttribution shared].options = options;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) handleOpenUrl:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation{
|
||||
if(self.isBridgeReady == YES){
|
||||
[[AppsFlyerLib shared] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation];
|
||||
}else{
|
||||
[AppsFlyerAttribution shared].url = url;
|
||||
[AppsFlyerAttribution shared].sourceApplication = sourceApplication;
|
||||
[AppsFlyerAttribution shared].annotation = annotation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void) receiveBridgeReadyNotification:(NSNotification *) notification
|
||||
{
|
||||
NSLog (@"AppsFlyer Debug: handle deep link");
|
||||
if(self.url && self.sourceApplication){
|
||||
[[AppsFlyerLib shared] handleOpenURL:self.url sourceApplication:self.sourceApplication withAnnotation:self.annotation];
|
||||
self.url = nil;
|
||||
self.sourceApplication = nil;
|
||||
self.annotation = nil;
|
||||
}else if(self.options && self.url){
|
||||
[[AppsFlyerLib shared] handleOpenUrl:self.url options:self.options];
|
||||
self.options = nil;
|
||||
self.url = nil;
|
||||
}else if(self.userActivity){
|
||||
[[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:nil];
|
||||
self.userActivity = nil;
|
||||
self.restorationHandler = nil;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1060e47d7b9e2453ba575f0b455b2bf8
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// AppsFlyeriOSWarpper.h
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by Jonathan Wesfield on 24/07/2019.
|
||||
//
|
||||
|
||||
#import "AFUnityUtils.mm"
|
||||
#import "UnityAppController.h"
|
||||
#import "AppsFlyerAttribution.h"
|
||||
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||
#else
|
||||
#import "AppsFlyerLib.h"
|
||||
#endif
|
||||
|
||||
@interface AppsFlyeriOSWarpper : NSObject <AppsFlyerLibDelegate, AppsFlyerDeepLinkDelegate>
|
||||
+ (BOOL) didCallStart;
|
||||
+ (void) setDidCallStart:(BOOL)val;
|
||||
@end
|
||||
|
||||
|
||||
static AppsFlyeriOSWarpper *_AppsFlyerdelegate;
|
||||
static const int kPushNotificationSize = 32;
|
||||
|
||||
static NSString* ConversionDataCallbackObject = @"AppsFlyerObject";
|
||||
|
||||
static const char* VALIDATE_CALLBACK = "didFinishValidateReceipt";
|
||||
static const char* VALIDATE_ERROR_CALLBACK = "didFinishValidateReceiptWithError";
|
||||
static const char* GCD_CALLBACK = "onConversionDataSuccess";
|
||||
static const char* GCD_ERROR_CALLBACK = "onConversionDataFail";
|
||||
static const char* OAOA_CALLBACK = "onAppOpenAttribution";
|
||||
static const char* OAOA_ERROR_CALLBACK = "onAppOpenAttributionFailure";
|
||||
static const char* GENERATE_LINK_CALLBACK = "onInviteLinkGenerated";
|
||||
static const char* OPEN_STORE_LINK_CALLBACK = "onOpenStoreLinkGenerated";
|
||||
static const char* START_REQUEST_CALLBACK = "requestResponseReceived";
|
||||
static const char* IN_APP_RESPONSE_CALLBACK = "inAppResponseReceived";
|
||||
static const char* ON_DEEPLINKING = "onDeepLinking";
|
||||
static const char* VALIDATE_AND_LOG_V2_CALLBACK = "onValidateAndLogComplete";
|
||||
static const char* VALIDATE_AND_LOG_V2_ERROR_CALLBACK = "onValidateAndLogFailure";
|
||||
|
||||
|
||||
static NSString* validateObjectName = @"";
|
||||
static NSString* openStoreObjectName = @"";
|
||||
static NSString* generateInviteObjectName = @"";
|
||||
static NSString* validateAndLogObjectName = @"";
|
||||
static NSString* startRequestObjectName = @"";
|
||||
static NSString* inAppRequestObjectName = @"";
|
||||
static NSString* onDeeplinkingObjectName = @"";
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 147104b04b5794eaa92b4195cc328e13
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,370 @@
|
||||
//
|
||||
// AppsFlyeriOSWarpper.mm
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by Jonathan Wesfield on 24/07/2019.
|
||||
//
|
||||
|
||||
#import "AppsFlyeriOSWrapper.h"
|
||||
|
||||
|
||||
static void unityCallBack(NSString* objectName, const char* method, const char* msg) {
|
||||
if(objectName){
|
||||
UnitySendMessage([objectName UTF8String], method, msg);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
const void _startSDK(bool shouldCallback, const char* objectName) {
|
||||
[[AppsFlyerLib shared] setPluginInfoWith: AFSDKPluginUnity
|
||||
pluginVersion:@"6.14.5"
|
||||
additionalParams:nil];
|
||||
startRequestObjectName = stringFromChar(objectName);
|
||||
AppsFlyeriOSWarpper.didCallStart = YES;
|
||||
[AppsFlyerAttribution shared].isBridgeReady = YES;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AF_BRIDGE_SET object: [AppsFlyerAttribution shared]];
|
||||
[[AppsFlyerLib shared] startWithCompletionHandler:^(NSDictionary<NSString *,id> *dictionary, NSError *error) {
|
||||
if(shouldCallback){
|
||||
if (error) {
|
||||
NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]};
|
||||
unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(callbackDictionary));
|
||||
return;
|
||||
}
|
||||
if (dictionary) {
|
||||
unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(dictionary));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
const void _setCustomerUserID (const char* customerUserID) {
|
||||
[[AppsFlyerLib shared] setCustomerUserID:stringFromChar(customerUserID)];
|
||||
}
|
||||
|
||||
const void _setAdditionalData (const char* customData) {
|
||||
[[AppsFlyerLib shared] setAdditionalData:dictionaryFromJson(customData)];
|
||||
}
|
||||
|
||||
const void _setAppsFlyerDevKey (const char* appsFlyerDevKey) {
|
||||
[AppsFlyerLib shared].appsFlyerDevKey = stringFromChar(appsFlyerDevKey);
|
||||
}
|
||||
|
||||
const void _setAppleAppID (const char* appleAppID) {
|
||||
[AppsFlyerLib shared].appleAppID = stringFromChar(appleAppID);
|
||||
}
|
||||
|
||||
const void _setCurrencyCode (const char* currencyCode) {
|
||||
[[AppsFlyerLib shared] setCurrencyCode:stringFromChar(currencyCode)];
|
||||
}
|
||||
|
||||
const void _setDisableCollectAppleAdSupport (bool disableAdvertisingIdentifier) {
|
||||
[AppsFlyerLib shared].disableAdvertisingIdentifier = disableAdvertisingIdentifier;
|
||||
}
|
||||
|
||||
const void _setIsDebug (bool isDebug) {
|
||||
[AppsFlyerLib shared].isDebug = isDebug;
|
||||
}
|
||||
|
||||
const void _setShouldCollectDeviceName (bool shouldCollectDeviceName) {
|
||||
[AppsFlyerLib shared].shouldCollectDeviceName = shouldCollectDeviceName;
|
||||
}
|
||||
|
||||
const void _setAppInviteOneLinkID (const char* appInviteOneLinkID) {
|
||||
[[AppsFlyerLib shared] setAppInviteOneLink:stringFromChar(appInviteOneLinkID)];
|
||||
}
|
||||
|
||||
const void _setDeepLinkTimeout (long deepLinkTimeout) {
|
||||
[AppsFlyerLib shared].deepLinkTimeout = deepLinkTimeout;
|
||||
}
|
||||
|
||||
const void _anonymizeUser (bool anonymizeUser) {
|
||||
[AppsFlyerLib shared].anonymizeUser = anonymizeUser;
|
||||
}
|
||||
|
||||
const void _enableTCFDataCollection (bool shouldCollectTcfData) {
|
||||
[[AppsFlyerLib shared] enableTCFDataCollection:shouldCollectTcfData];
|
||||
}
|
||||
|
||||
const void _setConsentData(bool isUserSubjectToGDPR, bool hasConsentForDataUsage, bool hasConsentForAdsPersonalization) {
|
||||
AppsFlyerConsent *consentData = nil;
|
||||
if (isUserSubjectToGDPR) {
|
||||
consentData = [[AppsFlyerConsent alloc] initForGDPRUserWithHasConsentForDataUsage:hasConsentForDataUsage hasConsentForAdsPersonalization:hasConsentForAdsPersonalization];
|
||||
} else {
|
||||
consentData = [[AppsFlyerConsent alloc] initNonGDPRUser];
|
||||
}
|
||||
[[AppsFlyerLib shared] setConsentData:consentData];
|
||||
}
|
||||
|
||||
const void _setDisableCollectIAd (bool disableCollectASA) {
|
||||
[AppsFlyerLib shared].disableCollectASA = disableCollectASA;
|
||||
}
|
||||
|
||||
const void _setUseReceiptValidationSandbox (bool useReceiptValidationSandbox) {
|
||||
[AppsFlyerLib shared].useReceiptValidationSandbox = useReceiptValidationSandbox;
|
||||
}
|
||||
|
||||
const void _setUseUninstallSandbox (bool useUninstallSandbox) {
|
||||
[AppsFlyerLib shared].useUninstallSandbox = useUninstallSandbox;
|
||||
}
|
||||
|
||||
const void _setResolveDeepLinkURLs (int length, const char **resolveDeepLinkURLs) {
|
||||
if(length > 0 && resolveDeepLinkURLs) {
|
||||
[[AppsFlyerLib shared] setResolveDeepLinkURLs:NSArrayFromCArray(length, resolveDeepLinkURLs)];
|
||||
}
|
||||
}
|
||||
|
||||
const void _setOneLinkCustomDomains (int length, const char **oneLinkCustomDomains) {
|
||||
if(length > 0 && oneLinkCustomDomains) {
|
||||
[[AppsFlyerLib shared] setOneLinkCustomDomains:NSArrayFromCArray(length, oneLinkCustomDomains)];
|
||||
}
|
||||
}
|
||||
|
||||
const void _afSendEvent (const char* eventName, const char* eventValues, bool shouldCallback, const char* objectName) {
|
||||
inAppRequestObjectName = stringFromChar(objectName);
|
||||
[[AppsFlyerLib shared] logEventWithEventName:stringFromChar(eventName) eventValues:dictionaryFromJson(eventValues) completionHandler:^(NSDictionary<NSString *,id> *dictionary, NSError *error) {
|
||||
if(shouldCallback){
|
||||
if (error) {
|
||||
NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]};
|
||||
unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(callbackDictionary));
|
||||
return;
|
||||
}
|
||||
if (dictionary) {
|
||||
unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(dictionary));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
const void _recordLocation (double longitude, double latitude) {
|
||||
[[AppsFlyerLib shared] logLocation:longitude latitude:latitude];
|
||||
}
|
||||
|
||||
const char* _getAppsFlyerId () {
|
||||
return getCString([[[AppsFlyerLib shared] getAppsFlyerUID] UTF8String]);
|
||||
}
|
||||
|
||||
const void _registerUninstall (unsigned char* deviceToken) {
|
||||
if(deviceToken){
|
||||
NSData* tokenData = [NSData dataWithBytes:(const void *)deviceToken length:sizeof(unsigned char)*kPushNotificationSize];
|
||||
[[AppsFlyerLib shared] registerUninstall:tokenData];
|
||||
}
|
||||
}
|
||||
|
||||
const void _handlePushNotification (const char* pushPayload) {
|
||||
[[AppsFlyerLib shared] handlePushNotification:dictionaryFromJson(pushPayload)];
|
||||
}
|
||||
|
||||
const char* _getSDKVersion () {
|
||||
return getCString([[[AppsFlyerLib shared] getSDKVersion] UTF8String]);
|
||||
}
|
||||
|
||||
const void _setHost (const char* host, const char* hostPrefix) {
|
||||
[[AppsFlyerLib shared] setHost:stringFromChar(host) withHostPrefix:stringFromChar(hostPrefix)];
|
||||
}
|
||||
|
||||
const void _setMinTimeBetweenSessions (int minTimeBetweenSessions) {
|
||||
[AppsFlyerLib shared].minTimeBetweenSessions = minTimeBetweenSessions;
|
||||
}
|
||||
|
||||
const void _stopSDK (bool isStopped) {
|
||||
[AppsFlyerLib shared].isStopped = isStopped;
|
||||
}
|
||||
|
||||
const BOOL _isSDKStopped () {
|
||||
return [AppsFlyerLib shared].isStopped;
|
||||
}
|
||||
|
||||
const void _handleOpenUrl(const char *url, const char *sourceApplication, const char *annotation) {
|
||||
[[AppsFlyerLib shared] handleOpenURL:[NSURL URLWithString:stringFromChar(url)] sourceApplication:stringFromChar(sourceApplication) withAnnotation:stringFromChar(annotation)]; }
|
||||
|
||||
const void _recordCrossPromoteImpression (const char* appID, const char* campaign, const char* parameters) {
|
||||
[AppsFlyerCrossPromotionHelper logCrossPromoteImpression:stringFromChar(appID) campaign:stringFromChar(campaign) parameters:dictionaryFromJson(parameters)]; }
|
||||
|
||||
const void _attributeAndOpenStore (const char* appID, const char* campaign, const char* parameters, const char* objectName) {
|
||||
|
||||
openStoreObjectName = stringFromChar(objectName);
|
||||
|
||||
[AppsFlyerCrossPromotionHelper
|
||||
logAndOpenStore:stringFromChar(appID)
|
||||
campaign:stringFromChar(campaign)
|
||||
parameters:dictionaryFromJson(parameters)
|
||||
openStore:^(NSURLSession * _Nonnull urlSession, NSURL * _Nonnull clickURL) {
|
||||
unityCallBack(openStoreObjectName, OPEN_STORE_LINK_CALLBACK, [clickURL.absoluteString UTF8String]);
|
||||
}];
|
||||
}
|
||||
|
||||
const void _generateUserInviteLink (const char* parameters, const char* objectName) {
|
||||
|
||||
generateInviteObjectName = stringFromChar(objectName);
|
||||
|
||||
[AppsFlyerShareInviteHelper generateInviteUrlWithLinkGenerator:^AppsFlyerLinkGenerator * _Nonnull(AppsFlyerLinkGenerator * _Nonnull generator) {
|
||||
return generatorFromDictionary(dictionaryFromJson(parameters), generator);
|
||||
} completionHandler:^(NSURL * _Nullable url) {
|
||||
unityCallBack(generateInviteObjectName, GENERATE_LINK_CALLBACK, [url.absoluteString UTF8String]);
|
||||
}];
|
||||
}
|
||||
|
||||
const void _recordInvite (const char* channel, const char* parameters) {
|
||||
[AppsFlyerShareInviteHelper logInvite:stringFromChar(channel) parameters:dictionaryFromJson(parameters)];
|
||||
}
|
||||
|
||||
const void _setUserEmails (int emailCryptTypeInt , int length, const char **userEmails) {
|
||||
if(length > 0 && userEmails) {
|
||||
[[AppsFlyerLib shared] setUserEmails:NSArrayFromCArray(length, userEmails) withCryptType:emailCryptTypeFromInt(emailCryptTypeInt)];
|
||||
}
|
||||
}
|
||||
|
||||
const void _setPhoneNumber (const char* phoneNumber) {
|
||||
[[AppsFlyerLib shared] setPhoneNumber:stringFromChar(phoneNumber)];
|
||||
}
|
||||
|
||||
const void _setSharingFilterForAllPartners () {
|
||||
[[AppsFlyerLib shared] setSharingFilterForAllPartners];
|
||||
}
|
||||
|
||||
const void _setSharingFilter (int length, const char **partners) {
|
||||
if(length > 0 && partners) {
|
||||
[[AppsFlyerLib shared] setSharingFilter:NSArrayFromCArray(length, partners)];
|
||||
}
|
||||
}
|
||||
|
||||
const void _setSharingFilterForPartners (int length, const char **partners) {
|
||||
if(length > 0 && partners) {
|
||||
[[AppsFlyerLib shared] setSharingFilterForPartners:NSArrayFromCArray(length, partners)];
|
||||
} else {
|
||||
[[AppsFlyerLib shared] setSharingFilterForPartners:nil];
|
||||
}
|
||||
}
|
||||
|
||||
const void _validateAndSendInAppPurchase (const char* productIdentifier, const char* price, const char* currency, const char* transactionId, const char* additionalParameters, const char* objectName) {
|
||||
|
||||
validateObjectName = stringFromChar(objectName);
|
||||
|
||||
[[AppsFlyerLib shared]
|
||||
validateAndLogInAppPurchase:stringFromChar(productIdentifier)
|
||||
price:stringFromChar(price)
|
||||
currency:stringFromChar(currency)
|
||||
transactionId:stringFromChar(transactionId)
|
||||
additionalParameters:dictionaryFromJson(additionalParameters)
|
||||
success:^(NSDictionary *result){
|
||||
unityCallBack(validateObjectName, VALIDATE_CALLBACK, stringFromdictionary(result));
|
||||
} failure:^(NSError *error, id response) {
|
||||
if(response && [response isKindOfClass:[NSDictionary class]]) {
|
||||
NSDictionary* value = (NSDictionary*)response;
|
||||
unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, stringFromdictionary(value));
|
||||
} else {
|
||||
unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, error ? [[error localizedDescription] UTF8String] : "error");
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
const void _validateAndSendInAppPurchaseV2 (const char* product, const char* price, const char* currency, const char* transactionId, const char* extraEventValues, const char* objectName) {
|
||||
|
||||
validateAndLogObjectName = stringFromChar(objectName);
|
||||
AFSDKPurchaseDetails *details = [[AFSDKPurchaseDetails alloc] initWithProductId:stringFromChar(product) price:stringFromChar(price) currency:stringFromChar(currency) transactionId:stringFromChar(transactionId)];
|
||||
|
||||
[[AppsFlyerLib shared]
|
||||
validateAndLogInAppPurchase:details
|
||||
extraEventValues:dictionaryFromJson(extraEventValues)
|
||||
completionHandler:^(AFSDKValidateAndLogResult * _Nullable result) {
|
||||
if (result.status == AFSDKValidateAndLogStatusSuccess) {
|
||||
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(result.result));
|
||||
} else if (result.status == AFSDKValidateAndLogStatusFailure) {
|
||||
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(result.errorData));
|
||||
} else {
|
||||
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_ERROR_CALLBACK, stringFromdictionary(dictionaryFromNSError(result.error)));
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
const void _getConversionData(const char* objectName) {
|
||||
if (_AppsFlyerdelegate == nil) {
|
||||
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||
}
|
||||
ConversionDataCallbackObject = stringFromChar(objectName);
|
||||
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||
}
|
||||
|
||||
const void _waitForATTUserAuthorizationWithTimeoutInterval (int timeoutInterval) {
|
||||
[[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:timeoutInterval];
|
||||
}
|
||||
|
||||
const void _disableSKAdNetwork (bool isDisabled) {
|
||||
[AppsFlyerLib shared].disableSKAdNetwork = isDisabled;
|
||||
}
|
||||
|
||||
const void _addPushNotificationDeepLinkPath (int length, const char **paths) {
|
||||
if(length > 0 && paths) {
|
||||
[[AppsFlyerLib shared] addPushNotificationDeepLinkPath:NSArrayFromCArray(length, paths)];
|
||||
}
|
||||
}
|
||||
|
||||
const void _subscribeForDeepLink (const char* objectName) {
|
||||
|
||||
onDeeplinkingObjectName = stringFromChar(objectName);
|
||||
|
||||
if (_AppsFlyerdelegate == nil) {
|
||||
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||
}
|
||||
[[AppsFlyerLib shared] setDeepLinkDelegate:_AppsFlyerdelegate];
|
||||
}
|
||||
|
||||
const void _setCurrentDeviceLanguage(const char* language) {
|
||||
[[AppsFlyerLib shared] setCurrentDeviceLanguage:stringFromChar(language)];
|
||||
}
|
||||
|
||||
const void _setPartnerData(const char* partnerId, const char* partnerInfo) {
|
||||
[[AppsFlyerLib shared] setPartnerDataWithPartnerId: stringFromChar(partnerId) partnerInfo:dictionaryFromJson(partnerInfo)];
|
||||
}
|
||||
|
||||
const void _disableIDFVCollection(bool isDisabled) {
|
||||
[AppsFlyerLib shared].disableIDFVCollection = isDisabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@implementation AppsFlyeriOSWarpper
|
||||
|
||||
static BOOL didCallStart;
|
||||
+ (BOOL) didCallStart
|
||||
{ @synchronized(self) { return didCallStart; } }
|
||||
+ (void) setDidCallStart:(BOOL)val
|
||||
{ @synchronized(self) { didCallStart = val; } }
|
||||
|
||||
- (void)onConversionDataSuccess:(NSDictionary *)installData {
|
||||
unityCallBack(ConversionDataCallbackObject, GCD_CALLBACK, stringFromdictionary(installData));
|
||||
}
|
||||
|
||||
- (void)onConversionDataFail:(NSError *)error {
|
||||
unityCallBack(ConversionDataCallbackObject, GCD_ERROR_CALLBACK, [[error localizedDescription] UTF8String]);
|
||||
}
|
||||
|
||||
- (void)onAppOpenAttribution:(NSDictionary *)attributionData {
|
||||
unityCallBack(ConversionDataCallbackObject, OAOA_CALLBACK, stringFromdictionary(attributionData));
|
||||
}
|
||||
|
||||
- (void)onAppOpenAttributionFailure:(NSError *)error {
|
||||
unityCallBack(ConversionDataCallbackObject, OAOA_ERROR_CALLBACK, [[error localizedDescription] UTF8String]);
|
||||
}
|
||||
|
||||
- (void)didResolveDeepLink:(AppsFlyerDeepLinkResult *)result{
|
||||
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
[dict setValue:stringFromDeepLinkResultError(result) forKey:@"error"];
|
||||
[dict setValue:stringFromDeepLinkResultStatus(result.status) forKey:@"status"];
|
||||
|
||||
if(result && result.deepLink){
|
||||
[dict setValue:result.deepLink.description forKey:@"deepLink"];
|
||||
[dict setValue:@(result.deepLink.isDeferred) forKey:@"is_deferred"];
|
||||
}
|
||||
|
||||
unityCallBack(onDeeplinkingObjectName, ON_DEEPLINKING, stringFromdictionary(dict));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bff3788f3d8747fe9679bd3818e1d76
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user