[M] sync n3

This commit is contained in:
2024-12-09 16:54:19 +08:00
parent c90bbe86e7
commit 05331e6286
845 changed files with 6138 additions and 1307 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dc9f548d434094d83b1c00e0cd0895ae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAAdjustSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAAdjustSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 5c2ee17250bf74b279745e7b20324386
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
//
// TAAdjustSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TAAdjustSyncData.h"
@implementation TAAdjustSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *accountID = [taInstance getAccountId] ? [taInstance getAccountId] : @"";
NSString *distinctId = [taInstance getDistinctId] ? [taInstance getDistinctId] : @"";
Class cls = NSClassFromString(@"Adjust");
SEL sel = NSSelectorFromString(@"addSessionCallbackParameter:value:");
if (cls && [cls respondsToSelector:sel]) {
[cls performSelector:sel withObject:TA_ACCOUNT_ID withObject:accountID];
[cls performSelector:sel withObject:TA_DISTINCT_ID withObject:distinctId];
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 5eb03a70bd3e04ffaa297aa9944119ab
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAAppLovinSyncData.h
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAAppLovinSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: bef7b8a1ee5a94c378327f8cc1fbd2c2
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
//
// TAAppLovinSyncData.m
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TAAppLovinSyncData.h"
@implementation TAAppLovinSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *distinctId = [taInstance getDistinctId] ? [taInstance getDistinctId] : @"";
static dispatch_once_t onceToken;
Class cls = NSClassFromString(@"ALSdk");
SEL sel1 = NSSelectorFromString(@"shared");
SEL sel2 = NSSelectorFromString(@"setUserIdentifier");
__block id instance;
dispatch_once(&onceToken, ^{
if (cls && [cls respondsToSelector:sel1]) {
instance = [cls performSelector:sel1];
if ([instance respondsToSelector:sel2]) {
[instance performSelector:sel2 withObject:distinctId];
}
}
});
if ([property isKindOfClass:[NSDictionary class]] && [property.allKeys containsObject:TASyncDataKey]) {
id customData = property[TASyncDataKey];
Class cls = NSClassFromString(@"MAAd");
if ([customData isKindOfClass:cls]) {
double revenue = [(NSNumber *)[customData performSelector:@selector(revenue)] doubleValue];
NSString *networkName = [customData performSelector:@selector(networkName)];
NSString *placement = [customData performSelector:@selector(placement)];
NSString *adUnitId = [customData performSelector:@selector(adUnitIdentifier)];
NSString *format = [[customData performSelector:@selector(format)] performSelector:@selector(label)];
NSString *countryCode = [instance valueForKeyPath:@"configuration.countryCode"];
[taInstance track:@"appLovin_sdk_ad_revenue" properties:@{
@"revenue":@(revenue),
@"networkName":networkName,
@"placement":placement,
@"adUnitId":adUnitId,
@"format":format,
@"countryCode":countryCode}];
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 6acd01cb07ff941398f5ac76b64d668b
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAAppsFlyerSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/2/14.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAAppsFlyerSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b808938d5a4ef44cd9417fcaa09304a4
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
//
// TAAppsFlyerSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/2/14.
//
#import "TAAppsFlyerSyncData.h"
@implementation TAAppsFlyerSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSMutableDictionary * datas = [NSMutableDictionary dictionaryWithDictionary:property];
NSString *accountID = [taInstance getAccountId];
NSString *distinctId = [taInstance getDistinctId];
[datas setObject:(accountID ? accountID : @"") forKey:TA_ACCOUNT_ID];
[datas setObject:distinctId ? distinctId : @"" forKey:TA_DISTINCT_ID];
Class cls = NSClassFromString(@"AppsFlyerLib");
SEL sel1 = NSSelectorFromString(@"shared");
SEL sel2 = NSSelectorFromString(@"setAdditionalData:");
if (cls && [cls respondsToSelector:sel1]) {
id instance = [cls performSelector:sel1];
if ([instance respondsToSelector:sel2]) {
[instance performSelector:sel2 withObject:datas];
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b373ccef5fc814dd3b5cca3544ef6d2e
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
//
// TABaseSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/2/14.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import "TAThirdPartySyncProtocol.h"
#define TA_DISTINCT_ID @"ta_distinct_id"
#define TA_ACCOUNT_ID @"ta_account_id"
#define td_force_inline __inline__ __attribute__((always_inline))
#define TASyncDataKey @"TASyncDataKey"
NS_ASSUME_NONNULL_BEGIN
static td_force_inline void __td_td__swizzleWithClassMethod(Class c, NSString *oriSELStr, SEL newSel, IMP newIMP) {
SEL orig = NSSelectorFromString(oriSELStr);
Method origMethod = class_getClassMethod(c, orig);
c = object_getClass((id)c);
class_addMethod(c, newSel, newIMP, method_getTypeEncoding(origMethod));
if(class_addMethod(c, orig, newIMP, method_getTypeEncoding(origMethod))) {
class_replaceMethod(c, newSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
Method newMethod = class_getClassMethod(c, newSel);
method_exchangeImplementations(origMethod, newMethod);
}
}
static td_force_inline void __td_td_swizzleWithOriSELStr(id target, NSString *oriSELStr, SEL newSEL, IMP newIMP) {
SEL origSEL = NSSelectorFromString(oriSELStr);
Method origMethod = class_getInstanceMethod([target class], origSEL);
if ([target respondsToSelector:origSEL]) {
class_addMethod([target class], newSEL, newIMP, method_getTypeEncoding(origMethod));
Method origMethod = class_getInstanceMethod([target class], origSEL);
Method newMethod = class_getInstanceMethod([target class], newSEL);
if(class_addMethod([target class], origSEL, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
class_replaceMethod([target class], newSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
} else {
class_addMethod([target class], origSEL, newIMP, method_getTypeEncoding(origMethod));
}
}
@interface TABaseSyncData : NSObject<TAThirdPartySyncProtocol>
@property (nonatomic, weak) id<TAThinkingTrackProtocol> taInstance;
@property (nonatomic, strong) NSDictionary *customPropety;
@property (nonatomic, assign) BOOL isSwizzleMethod;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 65771a2840d484c718e6166b779b5d9b
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
//
// TABaseSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/2/14.
//
#import "TABaseSyncData.h"
@implementation TABaseSyncData
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
self.taInstance = taInstance;
self.customPropety = property;
}
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance {
[self syncThirdData:taInstance property:@{}];
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 517862af209ce4ad4bd8002a327fed73
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TABranchSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TABranchSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: ca22a7263ae5145cba856e4bd480b2bb
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
//
// TABranchSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABranchSyncData.h"
@implementation TABranchSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *accountID = [taInstance getAccountId];
NSString *distinctId = [taInstance getDistinctId];
Class cls = NSClassFromString(@"Branch");
SEL sel1 = NSSelectorFromString(@"getInstance");
SEL sel2 = NSSelectorFromString(@"setRequestMetadataKey:value:");
if (cls && [cls respondsToSelector:sel1]) {
id instance = [cls performSelector:sel1];
if ([instance respondsToSelector:sel2]) {
[instance performSelector:sel2 withObject:TA_ACCOUNT_ID withObject:accountID];
[instance performSelector:sel2 withObject:TA_DISTINCT_ID withObject:distinctId];
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 14d24e07c10e04914806b65a10266790
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAFirebaseSyncData.h
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAFirebaseSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 05884726aff3f4d0a8705c380924ac0f
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
//
// TAFirebaseSyncData.m
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TAFirebaseSyncData.h"
@implementation TAFirebaseSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *distinctId = [taInstance getDistinctId] ? [taInstance getDistinctId] : @"";
Class cls = NSClassFromString(@"FIRAnalytics");
SEL sel = NSSelectorFromString(@"setUserID:");
if (cls && [cls respondsToSelector:sel]) {
[cls performSelector:sel withObject:distinctId];
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: f55372f8b0d004744a0d5601f3bdf1e5
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAIronSourceSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/2/16.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAIronSourceSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 7fccbd96cdae8450181ef923883295d9
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
//
// TAIronSourceSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/2/16.
//
#import "TAIronSourceSyncData.h"
@implementation TAIronSourceSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
static id _td_last_IronSource_delegate;
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance {
[super syncThirdData:taInstance];
if (self.isSwizzleMethod) return;
Class class = NSClassFromString(@"IronSource");
NSString *oriSELString = @"addImpressionDataDelegate:";
SEL newSel = NSSelectorFromString([NSString stringWithFormat:@"td_%@", oriSELString]);
IMP newIMP = imp_implementationWithBlock(^(id _self, id delegate) {
if ([_self respondsToSelector:newSel]) {
[_self performSelector:newSel withObject:delegate];
_td_last_IronSource_delegate = delegate;
}
id class1 = delegate;
NSString *oriSELString1 = @"impressionDataDidSucceed:";
SEL newSel1 = NSSelectorFromString([NSString stringWithFormat:@"td_%@", oriSELString1]);
IMP newIMP1 = imp_implementationWithBlock(^(id _self1, id impressionData) {
if ([_self1 respondsToSelector:newSel1]) {
[_self1 performSelector:newSel1 withObject:impressionData];
}
NSDictionary *all_data;
SEL sel = NSSelectorFromString(@"all_data");
if ([impressionData respondsToSelector:sel]) {
all_data = [impressionData performSelector:sel];
}
if (_td_last_IronSource_delegate == _self1) {
[self.taInstance track:@"ta_ironSource_callback" properties:all_data];
}
});
__td_td_swizzleWithOriSELStr(class1, oriSELString1, newSel1, newIMP1);
});
__td_td__swizzleWithClassMethod(class, oriSELString, newSel, newIMP);
self.isSwizzleMethod = YES;
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 50723cb7b78a24331b43bba7ee34caf4
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAKochavaSyncData.h
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAKochavaSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 5908d2c27b80a489dae892a870b74de1
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
//
// TAKochavaSyncData.m
// ThinkingSDK.default-Base-Core-Extension-Util-iOS
//
// Created by wwango on 2022/9/28.
//
#import "TAKochavaSyncData.h"
@implementation TAKochavaSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *accountID = [taInstance getAccountId];
NSString *distinctId = [taInstance getDistinctId];
Class cls = NSClassFromString(@"KVATracker");
SEL sel = NSSelectorFromString(@"shared");
SEL sel1 = NSSelectorFromString(@"identityLink");
SEL sel2 = NSSelectorFromString(@"registerWithNameString:identifierString:");
if (cls && [cls respondsToSelector:sel]) {
id shared = [cls performSelector:sel];
if (shared && [shared respondsToSelector:sel1]) {
id identityLink = [shared performSelector:sel1];
if (identityLink && [identityLink respondsToSelector:sel2]) {
[identityLink performSelector:sel2 withObject:TA_ACCOUNT_ID withObject:(accountID ? accountID : @"")];
[identityLink performSelector:sel2 withObject:TA_DISTINCT_ID withObject:(distinctId ? distinctId : @"")];
}
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 9dfff7df542cd401fa7592b206725a02
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TAReYunSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAReYunSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: e64632bcc60a04ad78c1baa60002266c
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
//
// TAReYunSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TAReYunSyncData.h"
@implementation TAReYunSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSString *distinctId = [taInstance getDistinctId] ? [taInstance getDistinctId] : @"";
Class cls = NSClassFromString(@"Tracking");
SEL sel = NSSelectorFromString(@"setRegisterWithAccountID:");
if (cls && [cls respondsToSelector:sel]) {
[cls performSelector:sel withObject: distinctId];
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: fb3609527c6d545288b56199264a3800
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
//
// TAThirdParty.h
// TAThirdParty
//
// Created by Charles on 9.1.23.
//
#import <Foundation/Foundation.h>
//! Project version number for TAThirdParty.
FOUNDATION_EXPORT double TAThirdPartyVersionNumber;
//! Project version string for TAThirdParty.
FOUNDATION_EXPORT const unsigned char TAThirdPartyVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TAThirdParty/PublicHeader.h>

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 97f6ec784b7384c92ac47dcd94bf5d5a
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
//
// TAThirdPartyManager.h
// ThinkingSDK
//
// Created by wwango on 2022/2/11.
//
#import <Foundation/Foundation.h>
#import "TAThirdPartySyncProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface TAThirdPartyManager : NSObject<TAThirdPartyProtocol>
- (void)enableThirdPartySharing:(NSNumber *)type instance:(id<TAThinkingTrackProtocol>)instance;
- (void)enableThirdPartySharing:(NSNumber *)type instance:(id<TAThinkingTrackProtocol>)instance property:(NSDictionary *)property;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 17cf558a565af4f988f6a4a875217e78
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,168 @@
//
// TAThirdPartyManager.m
// ThinkingSDK
//
// Created by wwango on 2022/2/11.
//
#import "TAThirdPartyManager.h"
#import "TAAppsFlyerSyncData.h"
#import "TAIronSourceSyncData.h"
#import "TAAdjustSyncData.h"
#import "TABranchSyncData.h"
#import "TATopOnSyncData.h"
#import "TAReYunSyncData.h"
#import "TATradPlusSyncData.h"
#import "TAKochavaSyncData.h"
typedef NS_OPTIONS(NSInteger, TAInnerThirdPartyShareType) {
TAInnerThirdPartyShareTypeNONE = 0,
TAInnerThirdPartyShareTypeAPPSFLYER = 1 << 0,
TAInnerThirdPartyShareTypeIRONSOURCE = 1 << 1,
TAInnerThirdPartyShareTypeADJUST = 1 << 2,
TAInnerThirdPartyShareTypeBRANCH = 1 << 3,
TAInnerThirdPartyShareTypeTOPON = 1 << 4,
TAInnerThirdPartyShareTypeTRACKING = 1 << 5,
TAInnerThirdPartyShareTypeTRADPLUS = 1 << 6,
TAInnerThirdPartyShareTypeAPPLOVIN = 1 << 7,
TAInnerThirdPartyShareTypeKOCHAVA = 1 << 8,
TAInnerThirdPartyShareTypeTALKINGDATA = 1 << 9,
TAInnerThirdPartyShareTypeFIREBASE = 1 << 10,
};
static NSMutableDictionary *_thirdPartyManagerMap;
// Register a third-party data collection service, and when the APP starts, it will start from the data area
char * kThinkingServices_service __attribute((used, section("__DATA, ThinkingServices"))) = "{ \"TAThirdPartyProtocol\" : \"TAThirdPartyManager\"}";
@interface TAThirdPartyManager()<TAThirdPartyProtocol>
@end
@implementation TAThirdPartyManager
- (instancetype)init
{
self = [super init];
if (self) {
_thirdPartyManagerMap = [NSMutableDictionary dictionary];
}
return self;
}
- (void)enableThirdPartySharing:(NSNumber *)type instance:(id<TAThinkingTrackProtocol>)instance
{
[self enableThirdPartySharing:type instance:instance property:@{}];
}
- (void)enableThirdPartySharing:(NSNumber *)typee instance:(id<TAThinkingTrackProtocol>)instance property:(NSDictionary *)property
{
NSDictionary *info = [self _getThridInfoWithType:typee];
NSString *libClass = info[@"libClass"];
NSString *taThirdClass = info[@"taThirdClass"];
NSString *errorMes = info[@"errorMes"];
if (!NSClassFromString(libClass)) {
NSLog(@"[THINKING] %@", errorMes);
}else {
id<TAThirdPartySyncProtocol> syncData = [_thirdPartyManagerMap objectForKey:taThirdClass];
if (!syncData) {
syncData = [NSClassFromString(taThirdClass) new];
[_thirdPartyManagerMap setObject:syncData forKey:taThirdClass];
}
[syncData syncThirdData:instance property:[property copy]];
NSLog(@"[THINKING] %@ , SyncThirdData Success", NSClassFromString(libClass));
}
}
- (NSDictionary *)_getThridInfoWithType:(NSNumber *)typee {
static NSDictionary *_ta_ThridInfo;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_ta_ThridInfo = @{
@(TAInnerThirdPartyShareTypeAPPSFLYER):@{
@"libClass": @"AppsFlyerLib",
@"taThirdClass":@"TAAppsFlyerSyncData",
@"errorMes":@"AppsFlyer Data synchronization exception: not installed AppsFlyer SDK"
},
@(TAInnerThirdPartyShareTypeIRONSOURCE):@{
@"libClass": @"IronSource",
@"taThirdClass":@"TAIronSourceSyncData",
@"errorMes": @"IronSource Data synchronization exception: not installed IronSource SDK"
},
@(TAInnerThirdPartyShareTypeADJUST):@{
@"libClass": @"Adjust",
@"taThirdClass":@"TAAdjustSyncData",
@"errorMes": @"Adjust Data synchronization exception: not installed Adjust SDK"
},
@(TAInnerThirdPartyShareTypeBRANCH):@{
@"libClass": @"Branch",
@"taThirdClass":@"TABranchSyncData",
@"errorMes": @"Branch Data synchronization exception: not installed Branch SDK"
},
@(TAInnerThirdPartyShareTypeTOPON):@{
@"libClass": @"ATAPI",
@"taThirdClass":@"TATopOnSyncData",
@"errorMes": @"TopOn Data synchronization exception: not installed TopOn SDK"
},
@(TAInnerThirdPartyShareTypeTRACKING):@{
@"libClass": @"Tracking",
@"taThirdClass":@"TAReYunSyncData",
@"errorMes": @"ReYun Data synchronization exception: Data synchronization exception: not installed SDK"
},
@(TAInnerThirdPartyShareTypeTRADPLUS):@{
@"libClass": @"TradPlus",
@"taThirdClass":@"TATradPlusSyncData",
@"errorMes": @"TradPlus Data synchronization exception: not installed TradPlus SDK"
},
@(TAInnerThirdPartyShareTypeAPPLOVIN):@{
@"libClass": @"ALSdk",
@"taThirdClass":@"TAAppLovinSyncData",
@"errorMes": @"AppLovin Data synchronization exception: not installed AppLovin SDK"
},
@(TAInnerThirdPartyShareTypeKOCHAVA):@{
@"libClass": @"KVATracker",
@"taThirdClass":@"TAKochavaSyncData",
@"errorMes": @"Kochava Data synchronization exception: not installed Kochava SDK"
},
@(TAInnerThirdPartyShareTypeFIREBASE):@{
@"libClass": @"FIRAnalytics",
@"taThirdClass":@"TAFirebaseSyncData",
@"errorMes": @"FIREBASE Data synchronization exception: not installed FIRAnalytics SDK"
},
};
});
return _ta_ThridInfo[typee];
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 6a1080195ae5b4aea9bc7c1589134f3f
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
//
// TAThirdPartySyncProtocol.h
// ThinkingSDKDEMO
//
// Created by wwango on 2022/2/17.
// Copyright © 2022 thinking. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol TAThinkingTrackProtocol <NSObject>
- (void)track:(NSString *)event properties:(nullable NSDictionary *)propertieDict;
- (NSString *)getDistinctId;
- (NSString *)getAccountId;
@end
@protocol TAThirdPartySyncProtocol <NSObject>
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance;
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property;
@end
@protocol TAThirdPartyProtocol <NSObject>
- (void)enableThirdPartySharing:(NSNumber *)type instance:(id<TAThinkingTrackProtocol>)instance;
- (void)enableThirdPartySharing:(NSNumber *)type instance:(id<TAThinkingTrackProtocol>)instance property:(NSDictionary *)property;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: d31a489f12eb54653b5cf6444e4245d6
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TATopOnSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TATopOnSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 9cb377c463bc14281934790c36a376c0
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
//
// TATopOnSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TATopOnSyncData.h"
@implementation TATopOnSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSMutableDictionary * datas = [NSMutableDictionary dictionaryWithDictionary:property];
NSString *accountID = [taInstance getAccountId];
NSString *distinctId = [taInstance getDistinctId];
[datas setObject:(accountID ? accountID : @"") forKey:TA_ACCOUNT_ID];
[datas setObject:distinctId ? distinctId : @"" forKey:TA_DISTINCT_ID];
Class cls = NSClassFromString(@"ATAPI");
SEL sel1 = NSSelectorFromString(@"sharedInstance");
SEL sel2 = NSSelectorFromString(@"setCustomData:");
if (cls && [cls respondsToSelector:sel1]) {
id instance = [cls performSelector:sel1];
if ([instance respondsToSelector:sel2]) {
[instance performSelector:sel2 withObject:datas];
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: dbca3c50b30be4ef88f32c10856288c8
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// TATradPlusSyncData.h
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TABaseSyncData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TATradPlusSyncData : TABaseSyncData
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: f0682c1aaffe14280b29c0bd11d0954e
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
//
// TATradPlusSyncData.m
// ThinkingSDK
//
// Created by wwango on 2022/3/25.
//
#import "TATradPlusSyncData.h"
@implementation TATradPlusSyncData
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void)syncThirdData:(id<TAThinkingTrackProtocol>)taInstance property:(NSDictionary *)property {
if (!self.customPropety || [self.customPropety isKindOfClass:[NSDictionary class]]) {
self.customPropety = @{};
}
NSMutableDictionary * datas = [NSMutableDictionary dictionaryWithDictionary:property];
// NSString *accountID = [taInstance getAccountId];
NSString *distinctId = [taInstance getDistinctId];
// [datas setObject:(accountID ? accountID : @"") forKey:TA_ACCOUNT_ID];
[datas setObject:distinctId ? distinctId : @"" forKey:TA_DISTINCT_ID];
Class cls = NSClassFromString(@"TradPlus");
SEL sel1 = NSSelectorFromString(@"sharedInstance");
SEL sel2 = NSSelectorFromString(@"setDicCustomValue:");
if (cls && [cls respondsToSelector:sel1]) {
id instance = [cls performSelector:sel1];
if ([instance respondsToSelector:sel2]) {
[instance performSelector:sel2 withObject:datas];
}
}
}
#pragma clang diagnostic pop
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: e00d06dbb27e94407b943499f2d08daf
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,517 @@
#if __has_include(<ThinkingSDK/ThinkingAnalyticsSDK.h>)
#import <ThinkingSDK/ThinkingAnalyticsSDK.h>
#import <ThinkingSDK/TDDeviceInfo.h>
#else
#import "ThinkingAnalyticsSDK.h"
#import "TDDeviceInfo.h"
#endif
#import <pthread.h>
#define NETWORK_TYPE_DEFAULT 1
#define NETWORK_TYPE_WIFI 2
#define NETWORK_TYPE_ALL 3
typedef const char * (*ResultHandler) (const char *type, const char *jsonData);
static ResultHandler resultHandler;
void RegisterRecieveGameCallback(ResultHandler handlerPointer)
{
resultHandler = handlerPointer;
}
static NSMutableDictionary *light_instances;
static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
ThinkingAnalyticsSDK* ta_getInstance(NSString *app_id) {
ThinkingAnalyticsSDK *result = nil;
if (app_id == nil || [app_id isEqualToString:@""]) {
return [ThinkingAnalyticsSDK sharedInstance];
}
pthread_rwlock_rdlock(&rwlock);
if (light_instances[app_id] != nil) {
result = light_instances[app_id];
}
pthread_rwlock_unlock(&rwlock);
if (result != nil) return result;
return [ThinkingAnalyticsSDK sharedInstanceWithAppid: app_id];
}
void ta_convertToDictionary(const char *json, NSDictionary **properties_dict) {
NSString *json_string = json != NULL ? [NSString stringWithUTF8String:json] : nil;
if (json_string) {
*properties_dict = [NSJSONSerialization JSONObjectWithData:[json_string dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
}
}
NSDictionary * ta_parse_date(NSDictionary *properties_dict) {
NSMutableDictionary *properties = [NSMutableDictionary dictionary];
for (NSString *key in properties_dict.allKeys) {
id value = properties_dict[key];
if ([value isKindOfClass:[NSDate class]]) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS";
NSString *dateStr = [formatter stringFromDate:(NSDate *)value];
properties[key] = dateStr;
} else if ([value isKindOfClass:[NSDictionary class]]) {
properties[key] = ta_parse_date((NSDictionary *)value);
} else {
properties[key] = value;
}
}
return properties;
}
char* ta_strdup(const char* string) {
if (string == NULL)
return NULL;
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
void ta_start(const char *app_id, const char *url, int mode, const char *timezone_id, bool enable_encrypt, int encrypt_version, const char *encrypt_public_key, int pinning_mode, bool allow_invalid_certificates, bool validates_domain_name, const char *instance_name) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *url_string = url != NULL ? [NSString stringWithUTF8String:url] : nil;
NSString *instance_name_string = instance_name != NULL ? [NSString stringWithUTF8String:instance_name] : nil;
TDConfig *config = [[TDConfig alloc] init];
config.appid = app_id_string;
config.configureURL = url_string;
if (instance_name) {
[config setName:instance_name_string];
}
if (mode == 1) {
// DEBUG
config.debugMode = ThinkingAnalyticsDebug;
} else if (mode == 2) {
// DEBUG_ONLY
config.debugMode = ThinkingAnalyticsDebugOnly;
}
NSString *timezone_id_string = timezone_id != NULL ? [NSString stringWithUTF8String:timezone_id] : nil;
NSTimeZone *timezone = [NSTimeZone timeZoneWithName:timezone_id_string];
if (timezone) {
config.defaultTimeZone = timezone;
}
if (enable_encrypt == YES) {
NSString *encrypt_public_key_string = encrypt_public_key != NULL ? [NSString stringWithUTF8String:encrypt_public_key] : nil;
// Enable data encryption
config.enableEncrypt = YES;
// Set public key and version
config.secretKey = [[TDSecretKey alloc] initWithVersion:encrypt_version publicKey:encrypt_public_key_string];
}
[ThinkingAnalyticsSDK startWithConfig:config];
}
void ta_enable_log(BOOL enable_log) {
if (enable_log) {
[ThinkingAnalyticsSDK setLogLevel:TDLoggingLevelDebug];
} else {
[ThinkingAnalyticsSDK setLogLevel:TDLoggingLevelNone];
}
}
void ta_set_network_type(int type) {
switch (type) {
case NETWORK_TYPE_DEFAULT:
[ta_getInstance(nil) setNetworkType:TDNetworkTypeDefault];
break;
case NETWORK_TYPE_WIFI:
[ta_getInstance(nil) setNetworkType:TDNetworkTypeOnlyWIFI];
break;
case NETWORK_TYPE_ALL:
[ta_getInstance(nil) setNetworkType:TDNetworkTypeALL];
break;
}
}
void ta_identify(const char *app_id, const char *unique_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *id_string = unique_id != NULL ? [NSString stringWithUTF8String:unique_id] : nil;
[ta_getInstance(app_id_string) identify:id_string];
}
const char *ta_get_distinct_id(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *distinct_id =[ta_getInstance(app_id_string) getDistinctId];
return ta_strdup([distinct_id UTF8String]);
}
void ta_login(const char *app_id, const char *account_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *id_string = account_id != NULL ? [NSString stringWithUTF8String:account_id] : nil;
[ta_getInstance(app_id_string) login:id_string];
}
void ta_logout(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) logout];
}
void ta_config_custom_lib_info(const char *lib_name, const char *lib_version) {
NSString *lib_name_string = lib_name != NULL ? [NSString stringWithUTF8String:lib_name] : nil;
NSString *lib_version_string = lib_version != NULL ? [NSString stringWithUTF8String:lib_version] : nil;
[ThinkingAnalyticsSDK setCustomerLibInfoWithLibName:lib_name_string libVersion:lib_version_string];
}
void ta_track_event(const char *app_id, const char *event_model_json) {
NSDictionary *event_model_dic = nil;
ta_convertToDictionary(event_model_json, &event_model_dic);
TDEventModel *eventModel;
NSString *eventType = event_model_dic[@"event_type"];
if ([eventType isEqualToString:@"track_first"]) {
eventModel = [[TDFirstEventModel alloc] initWithEventName:event_model_dic[@"event_name"] firstCheckID:event_model_dic[@"extra_id"]];
} else if ([eventType isEqualToString:@"track_update"]) {
eventModel = [[TDUpdateEventModel alloc] initWithEventName:event_model_dic[@"event_name"] eventID:event_model_dic[@"extra_id"]];
} else if ([eventType isEqualToString:@"track_overwrite"]) {
eventModel = [[TDOverwriteEventModel alloc] initWithEventName:event_model_dic[@"event_name"] eventID:event_model_dic[@"extra_id"]];
}
eventModel.properties = event_model_dic[@"event_properties"];
long event_time = [event_model_dic[@"event_time"] longValue];
NSString *timezoneString = event_model_dic[@"event_timezone"];
NSTimeZone *tz;
if ([@"Local" isEqualToString:timezoneString]) {
tz = [NSTimeZone localTimeZone];
} else {
tz = [NSTimeZone timeZoneWithName:timezoneString];
}
if (event_time) {
NSDate *date = [NSDate dateWithTimeIntervalSince1970:event_time/1000.0];
[eventModel configTime:date timeZone:tz];
}
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) trackWithEventModel:eventModel];
}
void ta_track(const char *app_id, const char *event_name, const char *properties, long long time_stamp_millis, const char *timezone) {
NSString *event_name_string = event_name != NULL ? [NSString stringWithUTF8String:event_name] : nil;
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
NSString *time_zone_string = timezone != NULL ? [NSString stringWithUTF8String:timezone] : nil;
NSTimeZone *tz;
if ([@"Local" isEqualToString:time_zone_string]) {
tz = [NSTimeZone localTimeZone];
} else {
tz = [NSTimeZone timeZoneWithName:time_zone_string];
}
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
if (tz) {
[ta_getInstance(app_id_string) track:event_name_string properties:properties_dict time:time timeZone:tz];
} else {
if (time_stamp_millis > 0) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[ta_getInstance(app_id_string) track:event_name_string properties:properties_dict time:time];
#pragma clang diagnostic pop
} else {
[ta_getInstance(app_id_string) track:event_name_string properties:properties_dict];
}
}
}
void ta_flush(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) flush];
}
void ta_set_super_properties(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) setSuperProperties:properties_dict];
}
}
void ta_unset_super_property(const char *app_id, const char *property_name) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *property_name_string = property_name != NULL ? [NSString stringWithUTF8String:property_name] : nil;
[ta_getInstance(app_id_string) unsetSuperProperty:property_name_string];
}
void ta_clear_super_properties(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) clearSuperProperties];
}
const char *ta_get_super_properties(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *property_dict = [ta_getInstance(app_id_string) currentSuperProperties];
// nsdictionary --> nsdata
NSData *data = [NSJSONSerialization dataWithJSONObject:property_dict options:kNilOptions error:nil];
// nsdata -> nsstring
NSString *jsonString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
return ta_strdup([jsonString UTF8String]);
}
const char *ta_get_preset_properties(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *property_dict = [[ta_getInstance(app_id_string) getPresetProperties] toEventPresetProperties];
// nsdate => nsstring
property_dict = ta_parse_date(property_dict);
// nsdictionary --> nsdata
NSData *data = [NSJSONSerialization dataWithJSONObject:property_dict options:kNilOptions error:nil];
// nsdata -> nsstring
NSString *jsonString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
return ta_strdup([jsonString UTF8String]);
}
void ta_time_event(const char *app_id, const char *event_name) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *event_name_string = event_name != NULL ? [NSString stringWithUTF8String:event_name] : nil;
[ta_getInstance(app_id_string) timeEvent:event_name_string];
}
void ta_user_set(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_set:properties_dict];
}
}
void ta_user_set_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_set:properties_dict withTime:time];
}
}
void ta_user_unset(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *properties_string = properties != NULL ? [NSString stringWithUTF8String:properties] : nil;
[ta_getInstance(app_id_string) user_unset:properties_string];
}
void ta_user_unset_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSString *properties_string = properties != NULL ? [NSString stringWithUTF8String:properties] : nil;
[ta_getInstance(app_id_string) user_unset:properties_string withTime:time];
}
void ta_user_set_once(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_setOnce:properties_dict];
}
}
void ta_user_set_once_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_setOnce:properties_dict withTime:time];
}
}
void ta_user_add(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_add:properties_dict];
}
}
void ta_user_add_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_add:properties_dict withTime:time];
}
}
void ta_user_delete(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) user_delete];
}
void ta_user_delete_with_time(const char *app_id, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) user_delete:time];
}
void ta_user_append(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_append:properties_dict];
}
}
void ta_user_append_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_append:properties_dict withTime:time];
}
}
void ta_user_uniq_append(const char *app_id, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_uniqAppend:properties_dict];
}
}
void ta_user_uniq_append_with_time(const char *app_id, const char *properties, long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) user_uniqAppend:properties_dict withTime:time];
}
}
const char *ta_get_device_id() {
NSString *distinct_id = [ta_getInstance(nil) getDeviceId];
return ta_strdup([distinct_id UTF8String]);
}
void ta_set_dynamic_super_properties(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) setAutoTrackDynamicProperties:^NSDictionary * _Nonnull{
const char *ret = resultHandler("DynamicSuperProperties", nil);
NSDictionary *dynamicSuperProperties = nil;
ta_convertToDictionary(ret, &dynamicSuperProperties);
return dynamicSuperProperties;
}];
}
void ta_set_track_status(const char *app_id, int status) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
ThinkingAnalyticsSDK* instance = ta_getInstance(app_id_string);
switch (status) {
case 1:
[instance setTrackStatus:TATrackStatusPause];
break;
case 2:
[instance setTrackStatus:TATrackStatusStop];
break;
case 3:
[instance setTrackStatus:TATrackStatusSaveOnly];
break;
case 4:
default:
[instance setTrackStatus:TATrackStatusNormal];
}
}
void ta_enable_tracking(const char *app_id, BOOL enabled) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) enableTracking:enabled];
}
void ta_opt_out_tracking(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) optOutTracking];
}
void ta_opt_out_tracking_and_delete_user(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) optOutTrackingAndDeleteUser];
}
void ta_opt_in_tracking(const char *app_id) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
[ta_getInstance(app_id_string) optInTracking];
}
void ta_create_light_instance(const char *delegate_app_id) {
NSString *delegate_app_id_string = delegate_app_id != NULL ? [NSString stringWithUTF8String:delegate_app_id] : nil;
ThinkingAnalyticsSDK *light = [ta_getInstance(nil) createLightInstance];
pthread_rwlock_wrlock(&rwlock);
if (light_instances == nil) {
light_instances = [NSMutableDictionary dictionary];
}
[light_instances setObject:light forKey:delegate_app_id_string];
pthread_rwlock_unlock(&rwlock);
}
void ta_enable_autoTrack(const char *app_id, int autoTrackEvents, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
[ta_getInstance(app_id_string) enableAutoTrack: autoTrackEvents properties:properties_dict];
}
void ta_enable_autoTrack_with_callback(const char *app_id, int autoTrackEvents) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
__block NSString * w_app_id_string = app_id_string;
[ta_getInstance(app_id_string) enableAutoTrack: autoTrackEvents callback:^NSDictionary * _Nonnull(ThinkingAnalyticsAutoTrackEventType eventType, NSDictionary * _Nonnull properties) {
NSMutableDictionary *callbackProperties = [NSMutableDictionary dictionaryWithDictionary:properties];
[callbackProperties setObject:@(eventType) forKey:@"EventType"];
[callbackProperties setObject:w_app_id_string forKey:@"AppID"];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ta_parse_date(callbackProperties) options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
const char *ret = resultHandler("AutoTrackProperties", [jsonString UTF8String]);
NSDictionary *autoTrackProperties = nil;
ta_convertToDictionary(ret, &autoTrackProperties);
return autoTrackProperties;
}];
}
void ta_set_autoTrack_properties(const char *app_id, int autoTrackEvents, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
[ta_getInstance(app_id_string) setAutoTrackProperties: autoTrackEvents properties:properties_dict];
}
const char *ta_get_time_string(long long time_stamp_millis) {
NSDate *time = [NSDate dateWithTimeIntervalSince1970:time_stamp_millis / 1000.0];
NSString *time_string = [ta_getInstance(nil) getTimeString:time];
return ta_strdup([time_string UTF8String]);
}
void ta_calibrate_time(long long time_stamp_millis) {
[ThinkingAnalyticsSDK calibrateTime:time_stamp_millis];
}
void ta_calibrate_time_with_ntp(const char *ntp_server) {
NSString *ntp_server_string = ntp_server != NULL ? [NSString stringWithUTF8String:ntp_server] : nil;
[ThinkingAnalyticsSDK calibrateTimeWithNtp:ntp_server_string];
}
void ta_enable_third_party_sharing(const char *app_id, int share_type, const char *properties) {
NSString *app_id_string = app_id != NULL ? [NSString stringWithUTF8String:app_id] : nil;
NSDictionary *properties_dict = nil;
ta_convertToDictionary(properties, &properties_dict);
if (properties_dict) {
[ta_getInstance(app_id_string) enableThirdPartySharing:share_type customMap:properties_dict];
} else {
[ta_getInstance(app_id_string) enableThirdPartySharing:share_type];
}
}

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 4a3a74316bafb412290585db3ac5a04e
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4dd9e7986fe964179ac6733ba24e44fe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Thinking</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3f0912fc584a54fccb105f957cec170d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b010dd865139b4ea8b8fe65c815bf3da
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e3aa65556739d487581dcbc33f001e23
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0f4211ddaee63483da2cf08a3b9dbed6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
//
// TDAPPPushParams.h
// ThinkingSDK
//
// Created by Charles on 6.5.23.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
extern id __td_get_userNotificationCenter(void);
extern id __td_get_userNotificationCenter_delegate(void);
extern NSDictionary * __td_get_userNotificationCenterResponse(id response);
extern NSString * __td_get_userNotificationCenterRequestContentTitle(id response);
extern NSString * __td_get_userNotificationCenterRequestContentBody(id response);
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: d606670f7a7c24e1d86b03c1fc6251ac
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
//
// TDAPPPushParams.m
// ThinkingSDK
//
// Created by Charles on 6.5.23.
//
#import "TDAPPPushParams.h"
id __td_get_userNotificationCenter(void) {
Class cls = NSClassFromString(@"UNUserNotificationCenter");
SEL sel = NSSelectorFromString(@"currentNotificationCenter");
if ([cls respondsToSelector:sel]) {
id (*getUserNotificationCenterIMP)(id, SEL) = (NSString * (*)(id, SEL))[cls methodForSelector:sel];
return getUserNotificationCenterIMP(cls, sel);
}
return nil;
}
id __td_get_userNotificationCenter_delegate(void) {
Class cls = NSClassFromString(@"UNUserNotificationCenter");
SEL sel = NSSelectorFromString(@"currentNotificationCenter");
SEL delegateSel = NSSelectorFromString(@"delegate");
if ([cls respondsToSelector:sel]) {
id (*getUserNotificationCenterIMP)(id, SEL) = (id (*)(id, SEL))[cls methodForSelector:sel];
id center = getUserNotificationCenterIMP(cls, sel);
if (center) {
id (*getUserNotificationCenterDelegateIMP)(id, SEL) = (id (*)(id, SEL))[center methodForSelector:delegateSel];
id delegate = getUserNotificationCenterDelegateIMP(center, delegateSel);
return delegate;
}
}
return nil;
}
NSDictionary * __td_get_userNotificationCenterResponse(id response) {
@try {
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
return [response valueForKeyPath:@"notification.request.content.userInfo"];
}
} @catch (NSException *exception) {
}
return nil;
}
NSString * __td_get_userNotificationCenterRequestContentTitle(id response) {
@try {
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
return [response valueForKeyPath:@"notification.request.content.title"];
}
} @catch (NSException *exception) {
}
return nil;
}
NSString * __td_get_userNotificationCenterRequestContentBody(id response) {
@try {
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
return [response valueForKeyPath:@"notification.request.content.body"];
}
} @catch (NSException *exception) {
}
return nil;
}

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 08ddbde4b0bb44a2781691f28d329404
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TDAppDelegateProxyManager : NSObject
+ (instancetype)defaultManager;
- (void)proxyNotifications;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 0ad802e76f93c418c9419315b8a3d275
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#import "TDAppDelegateProxyManager.h"
#import "TDApplicationDelegateProxy.h"
#import "TDNewSwizzle.h"
#import "UIApplication+TDPushClick.h"
#import "TDMethodHelper.h"
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import "TDUNUserNotificationCenterDelegateProxy.h"
#endif
@implementation TDAppDelegateProxyManager
+ (instancetype)defaultManager {
static dispatch_once_t onceToken;
static TDAppDelegateProxyManager *manager = nil;
dispatch_once(&onceToken, ^{
manager = [[TDAppDelegateProxyManager alloc] init];
});
return manager;
}
- (void)proxyNotifications NS_EXTENSION_UNAVAILABLE_IOS(""){
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[TDMethodHelper swizzleRespondsToSelector];
[TDApplicationDelegateProxy resolveOptionalSelectorsForDelegate:[UIApplication sharedApplication].delegate];
[TDApplicationDelegateProxy proxyDelegate:[UIApplication sharedApplication].delegate selectors:[NSSet setWithArray:@[@"application:didReceiveLocalNotification:",
@"application:didReceiveRemoteNotification:fetchCompletionHandler:",
@"application:handleOpenURL:",
@"application:openURL:options:",
@"application:continueUserActivity:restorationHandler:",
@"application:performActionForShortcutItem:completionHandler:"]]];
if (@available(iOS 10.0, *)) {
if ([UNUserNotificationCenter currentNotificationCenter].delegate) {
[TDUNUserNotificationCenterDelegateProxy proxyDelegate:[UNUserNotificationCenter currentNotificationCenter].delegate selectors:[NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]]];
}
NSError *error = NULL;
[UNUserNotificationCenter td_new_swizzleMethod:@selector(setDelegate:) withMethod:@selector(thinkingdata_setDelegate:) error:&error];
if (error) {
NSLog(@"proxy notification delegate error: %@", error);
}
}
});
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: ed11ab70d6d6943019d6d3995eeaadc2
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
#import "TDDelegateProxy.h"
NS_ASSUME_NONNULL_BEGIN
@interface TDApplicationDelegateProxy : TDDelegateProxy
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 47013b120f73c4885845dbb7dd840189
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
#import "TDApplicationDelegateProxy.h"
#import "TDClassHelper.h"
#import "NSObject+TDDelegateProxy.h"
#import "UIApplication+TDPushClick.h"
#import <objc/message.h>
#import "TDPresetProperties+TDDisProperties.h"
#import "TDAppLaunchReason.h"
#import "TDCommonUtil.h"
@implementation TDApplicationDelegateProxy
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
SEL selector = @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:);
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, userInfo, completionHandler];
[TDApplicationDelegateProxy trackEventWithTarget:self application:application remoteNotification:userInfo];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
SEL selector = @selector(application:didReceiveLocalNotification:);
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, notification];
[TDApplicationDelegateProxy trackEventWithTarget:self application:application localNotification:notification];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
SEL selector = @selector(application:continueUserActivity:restorationHandler:);
if (![TDPresetProperties disableStartReason]) {
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string: userActivity.webpageURL.absoluteString],@"data":@{}};
}
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:application arg2:userActivity arg3:restorationHandler];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
SEL selector = @selector(application:openURL:options:);
if (![TDPresetProperties disableStartReason]) {
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string:url.absoluteString],@"data":@{}};
}
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:app arg2:url arg3:options];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
SEL selector = @selector(application:handleOpenURL:);
if (![TDPresetProperties disableStartReason]) {
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": [TDCommonUtil string:url.absoluteString], @"data":@{}};
}
return [TDApplicationDelegateProxy invokeReturnBOOLWithTarget:self selector:selector arg1:application arg2:url];
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
SEL selector = @selector(application:performActionForShortcutItem:completionHandler:);
[TDApplicationDelegateProxy invokeWithTarget:self selector:selector, application, shortcutItem, completionHandler];
if (![TDPresetProperties disableStartReason]) {
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"",@"data": [TDCommonUtil dictionary:shortcutItem.userInfo]};
}
}
+ (void)trackEventWithTarget:(NSObject *)target application:(UIApplication *)application remoteNotification:(NSDictionary *)userInfo {
if (target != application.delegate) {
return;
}
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
NSLog(@"iOS version >= 10.0, callback for %@ was ignored.", @"application:didReceiveRemoteNotification:fetchCompletionHandler:");
return;
}
if (application.applicationState != UIApplicationStateInactive) {
return;
}
if (![TDPresetProperties disableStartReason]) {
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:userInfo]};
}
}
+ (void)trackEventWithTarget:(NSObject *)target application:(UIApplication *)application localNotification:(UILocalNotification *)notification {
if (target != application.delegate) {
return;
}
BOOL isValidPushClick = NO;
if (application.applicationState == UIApplicationStateInactive) {
isValidPushClick = YES;
}
if (!isValidPushClick) {
return;
}
if (![TDPresetProperties disableStartReason]) {
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
properties[@"alertBody"] = notification.alertBody;
if (@available(iOS 8.2, *)) {
properties[@"alertTitle"] = notification.alertTitle;
}
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:properties]};
}
}
+ (NSSet<NSString *> *)optionalSelectors {
return [NSSet setWithArray:@[@"application:didReceiveLocalNotification:",
@"application:didReceiveRemoteNotification:fetchCompletionHandler:",
@"application:handleOpenURL:",
@"application:openURL:options:",
@"application:continueUserActivity:restorationHandler:",
@"application:performActionForShortcutItem:completionHandler:"]];
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b2eec12b437e64f6886ebe51d6680b83
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
#import "TDDelegateProxy.h"
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import <UserNotifications/UserNotifications.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@interface TDUNUserNotificationCenterDelegateProxy : TDDelegateProxy
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: dd9eda5b6572748ecaa3313c288c9e16
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
#import "TDUNUserNotificationCenterDelegateProxy.h"
#import "TDClassHelper.h"
#import "NSObject+TDDelegateProxy.h"
#import <objc/message.h>
#import "TDAPPPushParams.h"
#import "TDPresetProperties+TDDisProperties.h"
#import "TDAppLaunchReason.h"
#import "TDCommonUtil.h"
@implementation TDUNUserNotificationCenterDelegateProxy
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){
SEL selector = @selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:);
[TDUNUserNotificationCenterDelegateProxy invokeWithTarget:self selector:selector, center, response, completionHandler];
[TDUNUserNotificationCenterDelegateProxy trackEventWithTarget:self notificationCenter:center notificationResponse:response];
}
+ (void)trackEventWithTarget:(NSObject *)target notificationCenter:(UNUserNotificationCenter *)center notificationResponse:(UNNotificationResponse *)response API_AVAILABLE(ios(10.0)){
if (target != center.delegate) {
return;
}
if (![TDPresetProperties disableStartReason]) {
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
NSDictionary *userInfo = __td_get_userNotificationCenterResponse(response);
if (userInfo) {
[properties addEntriesFromDictionary:userInfo];
}
properties[@"title"] = __td_get_userNotificationCenterRequestContentTitle(response);
properties[@"body"] = __td_get_userNotificationCenterRequestContentBody(response);
[[TDAppLaunchReason sharedInstance] clearAppLaunchParams];
[TDAppLaunchReason sharedInstance].appLaunchParams = @{@"url": @"", @"data": [TDCommonUtil dictionary:properties]};
}
if (![TDPresetProperties disableOpsReceiptProperties]) {
@try {
if ([response isKindOfClass:[NSClassFromString(@"UNNotificationResponse") class]]) {
NSDictionary *userInfo = [response valueForKeyPath:@"notification.request.content.userInfo"];
[TDAppLaunchReason td_ops_push_click:userInfo];
}
} @catch (NSException *exception) {
}
}
}
+ (NSSet<NSString *> *)optionalSelectors {
return [NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]];
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: a8c262d70355c46f38a4fce70eb95cc5
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIApplication (TDPushClick)
- (void)thinkingdata_setDelegate:(id <UIApplicationDelegate>)delegate;
@property (nonatomic, copy, nullable) NSDictionary *thinkingdata_launchOptions;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b039553b9411c4e30b4fc767b7c2714d
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
#import "UIApplication+TDPushClick.h"
#import "TDApplicationDelegateProxy.h"
#import <objc/runtime.h>
static void *const kSALaunchOptions = (void *)&kSALaunchOptions;
@implementation UIApplication (TDPushClick)
- (void)thinkingdata_setDelegate:(id<UIApplicationDelegate>)delegate {
[TDApplicationDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
[self thinkingdata_setDelegate:delegate];
if (!self.delegate) {
return;
}
[TDApplicationDelegateProxy proxyDelegate:self.delegate selectors:[NSSet setWithArray:@[@"application:didReceiveLocalNotification:", @"application:didReceiveRemoteNotification:fetchCompletionHandler:"]]];
}
- (NSDictionary *)thinkingdata_launchOptions {
return objc_getAssociatedObject(self, kSALaunchOptions);
}
- (void)setThinkingdata_launchOptions:(NSDictionary *)thinkingdata_launchOptions {
objc_setAssociatedObject(self, kSALaunchOptions, thinkingdata_launchOptions, OBJC_ASSOCIATION_COPY);
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 17463cb6f209545bcbc20aad5129804d
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import <UserNotifications/UserNotifications.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@interface UNUserNotificationCenter (TDPushClick)
- (void)thinkingdata_setDelegate:(id <UNUserNotificationCenterDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: dd78c300cef5f4507a13b638ce74c1e5
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
#import "UNUserNotificationCenter+TDPushClick.h"
#import "TDUNUserNotificationCenterDelegateProxy.h"
@implementation UNUserNotificationCenter (TDPushClick)
- (void)thinkingdata_setDelegate:(id<UNUserNotificationCenterDelegate>)delegate {
[TDUNUserNotificationCenterDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
[self thinkingdata_setDelegate:delegate];
if (!self.delegate) {
return;
}
[TDUNUserNotificationCenterDelegateProxy proxyDelegate:self.delegate selectors:[NSSet setWithArray:@[@"userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:"]]];
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 73166a65f020c46e8a3c53cfa301c5f2
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0aa41df3a429a4fd8915122407b7001a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
#import <Foundation/Foundation.h>
#import "TDDelegateProxyObject.h"
NS_ASSUME_NONNULL_BEGIN
@interface NSObject (TDDelegateProxy)
@property (nonatomic, copy, nullable) NSSet<NSString *> *thinkingdata_optionalSelectors;
@property (nonatomic, strong, nullable) TDDelegateProxyObject *thinkingdata_delegateObject;
/// hook respondsToSelector to resolve optional selectors
/// @param aSelector selector
- (BOOL)thinkingdata_respondsToSelector:(SEL)aSelector;
@end
@interface NSProxy (TDDelegateProxy)
@property (nonatomic, copy, nullable) NSSet<NSString *> *thinkingdata_optionalSelectors;
@property (nonatomic, strong, nullable) TDDelegateProxyObject *thinkingdata_delegateObject;
/// hook respondsToSelector to resolve optional selectors
/// @param aSelector selector
- (BOOL)thinkingdata_respondsToSelector:(SEL)aSelector;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: c165be5fc3eea4ab0bd9ff520104d3d8
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
#import "NSObject+TDDelegateProxy.h"
#import <objc/runtime.h>
static void *const kTDNSObjectDelegateOptionalSelectorsKey = (void *)&kTDNSObjectDelegateOptionalSelectorsKey;
static void *const kTDNSObjectDelegateObjectKey = (void *)&kTDNSObjectDelegateObjectKey;
static void *const kTDNSProxyDelegateOptionalSelectorsKey = (void *)&kTDNSProxyDelegateOptionalSelectorsKey;
static void *const kTDNSProxyDelegateObjectKey = (void *)&kTDNSProxyDelegateObjectKey;
@implementation NSObject (TDDelegateProxy)
- (NSSet<NSString *> *)thinkingdata_optionalSelectors {
return objc_getAssociatedObject(self, kTDNSObjectDelegateOptionalSelectorsKey);
}
- (void)setThinkingdata_optionalSelectors:(NSSet<NSString *> *)thinkingdata_optionalSelectors {
objc_setAssociatedObject(self, kTDNSObjectDelegateOptionalSelectorsKey, thinkingdata_optionalSelectors, OBJC_ASSOCIATION_COPY);
}
- (TDDelegateProxyObject *)thinkingdata_delegateObject {
return objc_getAssociatedObject(self, kTDNSObjectDelegateObjectKey);
}
- (void)setThinkingdata_delegateObject:(TDDelegateProxyObject *)thinkingdata_delegateObject {
objc_setAssociatedObject(self, kTDNSObjectDelegateObjectKey, thinkingdata_delegateObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)thinkingdata_respondsToSelector:(SEL)aSelector {
if ([self thinkingdata_respondsToSelector:aSelector]) {
return YES;
}
if ([self.thinkingdata_optionalSelectors containsObject:NSStringFromSelector(aSelector)]) {
return YES;
}
return NO;
}
@end
@implementation NSProxy (TDDelegateProxy)
- (NSSet<NSString *> *)thinkingdata_optionalSelectors {
return objc_getAssociatedObject(self, kTDNSProxyDelegateOptionalSelectorsKey);
}
- (void)setThinkingdata_optionalSelectors:(NSSet<NSString *> *)thinkingdata_optionalSelectors {
objc_setAssociatedObject(self, kTDNSProxyDelegateOptionalSelectorsKey, thinkingdata_optionalSelectors, OBJC_ASSOCIATION_COPY);
}
- (TDDelegateProxyObject *)thinkingdata_delegateObject {
return objc_getAssociatedObject(self, kTDNSProxyDelegateObjectKey);
}
- (void)setThinkingdata_delegateObject:(TDDelegateProxyObject *)thinkingdata_delegateObject {
objc_setAssociatedObject(self, kTDNSProxyDelegateObjectKey, thinkingdata_delegateObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)thinkingdata_respondsToSelector:(SEL)aSelector {
if ([self thinkingdata_respondsToSelector:aSelector]) {
return YES;
}
if ([self.thinkingdata_optionalSelectors containsObject:NSStringFromSelector(aSelector)]) {
return YES;
}
return NO;
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 852dc5d94530d4aff8a96973c9986ad2
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TDClassHelper : NSObject
+ (Class _Nullable)allocateClassWithObject:(id)object className:(NSString *)className;
+ (void)registerClass:(Class)cla;
+ (BOOL)setObject:(id)object toClass:(Class)cla;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b05b7c406ad1f43d0bb4f1be994d8765
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
#import "TDClassHelper.h"
#import <objc/runtime.h>
@implementation TDClassHelper
+ (Class _Nullable)allocateClassWithObject:(id)object className:(NSString *)className {
if (!object || className.length <= 0) {
return nil;
}
Class originalClass = object_getClass(object);
Class subclass = NSClassFromString(className);
if (subclass) {
return nil;
}
subclass = objc_allocateClassPair(originalClass, className.UTF8String, 0);
if (class_getInstanceSize(originalClass) != class_getInstanceSize(subclass)) {
return nil;
}
return subclass;
}
+ (void)registerClass:(Class)cla {
if (cla) {
objc_registerClassPair(cla);
}
}
+ (BOOL)setObject:(id)object toClass:(Class)cla {
if (cla && object && object_getClass(object) != cla) {
return object_setClass(object, cla);
}
return NO;
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: aec2711162866493884cdef2cc925bb0
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol TDHookDelegateProtocol <NSObject>
@optional
+ (NSSet<NSString *> *)optionalSelectors;
@end
@interface TDDelegateProxy : NSObject <TDHookDelegateProtocol>
+ (void)proxyDelegate:(id)delegate selectors:(NSSet<NSString *>*)selectors;
+ (void)invokeWithTarget:(NSObject *)target selector:(SEL)selector, ...;
+ (BOOL)invokeReturnBOOLWithTarget:(NSObject *)target selector:(SEL)selector arg1:(id)arg1 arg2:(id)arg2;
+ (BOOL)invokeReturnBOOLWithTarget:(NSObject *)target selector:(SEL)selector arg1:(id)arg1 arg2:(id)arg2 arg3:(id)arg3;
+ (void)resolveOptionalSelectorsForDelegate:(id)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: d844d7614eae8439c904288502d39b52
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,200 @@
#import "TDDelegateProxy.h"
#import "TDClassHelper.h"
#import "TDMethodHelper.h"
#import "NSObject+TDDelegateProxy.h"
#import <objc/message.h>
static NSString * const kTDNSObjectRemoveObserverSelector = @"removeObserver:forKeyPath:";
static NSString * const kTDNSObjectAddObserverSelector = @"addObserver:forKeyPath:options:context:";
static NSString * const kTDNSObjectClassSelector = @"class";
@implementation TDDelegateProxy
+ (void)proxyDelegate:(id)delegate selectors:(NSSet<NSString *> *)selectors {
if (object_isClass(delegate) || selectors.count == 0) {
return;
}
Class proxyClass = [self class];
NSMutableSet *delegateSelectors = [NSMutableSet setWithSet:selectors];
TDDelegateProxyObject *object = [delegate thinkingdata_delegateObject];
if (!object) {
object = [[TDDelegateProxyObject alloc] initWithDelegate:delegate proxy:proxyClass];
[delegate setThinkingdata_delegateObject:object];
}
[delegateSelectors minusSet:object.selectors];
if (delegateSelectors.count == 0) {
return;
}
if (object.thinkingClass) {
[self addInstanceMethodWithSelectors:delegateSelectors fromClass:proxyClass toClass:object.thinkingClass];
[object.selectors unionSet:delegateSelectors];
if (![object_getClass(delegate) isSubclassOfClass:object.thinkingClass]) {
[TDClassHelper setObject:delegate toClass:object.thinkingClass];
}
return;
}
if (object.kvoClass) {
if ([delegate isKindOfClass:NSObject.class] && ![object.selectors containsObject:kTDNSObjectRemoveObserverSelector]) {
[delegateSelectors addObject:kTDNSObjectRemoveObserverSelector];
}
[self addInstanceMethodWithSelectors:delegateSelectors fromClass:proxyClass toClass:object.kvoClass];
[object.selectors unionSet:delegateSelectors];
return;
}
Class thinkingClass = [TDClassHelper allocateClassWithObject:delegate className:object.thinkingClassName];
[TDClassHelper registerClass:thinkingClass];
if ([delegate isKindOfClass:NSObject.class] && ![object.selectors containsObject:kTDNSObjectAddObserverSelector]) {
[delegateSelectors addObject:kTDNSObjectAddObserverSelector];
}
if (![object.selectors containsObject:kTDNSObjectClassSelector]) {
[delegateSelectors addObject:kTDNSObjectClassSelector];
}
[self addInstanceMethodWithSelectors:delegateSelectors fromClass:proxyClass toClass:thinkingClass];
[object.selectors unionSet:delegateSelectors];
[TDClassHelper setObject:delegate toClass:thinkingClass];
}
+ (void)addInstanceMethodWithSelectors:(NSSet<NSString *> *)selectors fromClass:(Class)fromClass toClass:(Class)toClass {
for (NSString *selector in selectors) {
SEL sel = NSSelectorFromString(selector);
[TDMethodHelper addInstanceMethodWithSelector:sel fromClass:fromClass toClass:toClass];
}
}
+ (BOOL)invokeReturnBOOLWithTarget:(NSObject *)target selector:(SEL)selector arg1:(id)arg1 arg2:(id)arg2 arg3:(id)arg3 {
Class originalClass = target.thinkingdata_delegateObject.delegateISA;
struct objc_super targetSuper = {
.receiver = target,
.super_class = originalClass
};
BOOL returnValue = NO;
@try {
returnValue = ((BOOL (*)(struct objc_super *, SEL, id, id, id))objc_msgSendSuper)(&targetSuper, selector, arg1, arg2, arg3);
} @catch (NSException *exception) {
NSLog(@"msgSendSuper with exception: %@", exception);
} @finally {
}
return returnValue;
}
+ (BOOL)invokeReturnBOOLWithTarget:(NSObject *)target selector:(SEL)selector arg1:(id)arg1 arg2:(id)arg2 {
Class originalClass = target.thinkingdata_delegateObject.delegateISA;
struct objc_super targetSuper = {
.receiver = target,
.super_class = originalClass
};
BOOL returnValue = NO;
@try {
returnValue = ((BOOL (*)(struct objc_super *, SEL, id, id))objc_msgSendSuper)(&targetSuper, selector, arg1, arg2);
} @catch (NSException *exception) {
NSLog(@"msgSendSuper with exception: %@", exception);
} @finally {
}
return returnValue;
}
+ (void)invokeWithTarget:(NSObject *)target selector:(SEL)selector, ... {
Class originalClass = target.thinkingdata_delegateObject.delegateISA;
va_list args;
va_start(args, selector);
id arg1 = nil, arg2 = nil, arg3 = nil, arg4 = nil;
NSInteger count = [NSStringFromSelector(selector) componentsSeparatedByString:@":"].count - 1;
for (NSInteger i = 0; i < count; i++) {
i == 0 ? (arg1 = va_arg(args, id)) : nil;
i == 1 ? (arg2 = va_arg(args, id)) : nil;
i == 2 ? (arg3 = va_arg(args, id)) : nil;
i == 3 ? (arg4 = va_arg(args, id)) : nil;
}
struct objc_super targetSuper = {
.receiver = target,
.super_class = originalClass
};
@try {
void (*func)(struct objc_super *, SEL, id, id, id, id) = (void *)&objc_msgSendSuper;
func(&targetSuper, selector, arg1, arg2, arg3, arg4);
} @catch (NSException *exception) {
NSLog(@"msgSendSuper with exception: %@", exception);
} @finally {
va_end(args);
}
}
+ (void)resolveOptionalSelectorsForDelegate:(id)delegate {
if (object_isClass(delegate)) {
return;
}
NSSet *currentOptionalSelectors = ((NSObject *)delegate).thinkingdata_optionalSelectors;
NSMutableSet *optionalSelectors = [[NSMutableSet alloc] init];
if (currentOptionalSelectors) {
[optionalSelectors unionSet:currentOptionalSelectors];
}
if ([self respondsToSelector:@selector(optionalSelectors)] &&[self optionalSelectors]) {
[optionalSelectors unionSet:[self optionalSelectors]];
}
((NSObject *)delegate).thinkingdata_optionalSelectors = [optionalSelectors copy];
}
@end
#pragma mark - Class
@implementation TDDelegateProxy (Class)
- (Class)class {
if (self.thinkingdata_delegateObject.delegateClass) {
return self.thinkingdata_delegateObject.delegateClass;
}
return [super class];
}
@end
#pragma mark - KVO
@implementation TDDelegateProxy (KVO)
- (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context {
[super addObserver:observer forKeyPath:keyPath options:options context:context];
if (self.thinkingdata_delegateObject) {
[TDMethodHelper replaceInstanceMethodWithDestinationSelector:@selector(class) sourceSelector:@selector(class) fromClass:TDDelegateProxy.class toClass:object_getClass(self)];
}
}
- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath {
BOOL oldClassIsKVO = [TDDelegateProxyObject isKVOClass:object_getClass(self)];
[super removeObserver:observer forKeyPath:keyPath];
BOOL newClassIsKVO = [TDDelegateProxyObject isKVOClass:object_getClass(self)];
if (oldClassIsKVO && !newClassIsKVO) {
Class delegateProxy = self.thinkingdata_delegateObject.delegateProxy;
NSSet *selectors = [self.thinkingdata_delegateObject.selectors copy];
[self.thinkingdata_delegateObject removeKVO];
if ([delegateProxy respondsToSelector:@selector(proxyDelegate:selectors:)]) {
[delegateProxy proxyDelegate:self selectors:selectors];
}
}
}
@end

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 814fa739d0a0447259f0fda304b44e4e
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TDDelegateProxyObject : NSObject
@property (nonatomic, strong) Class delegateISA;
@property (nonatomic, strong, nullable) Class kvoClass;
@property (nonatomic, copy, nullable) NSString *thinkingClassName;
@property (nonatomic, strong, readonly, nullable) Class thinkingClass;
@property (nonatomic, strong) id delegateClass;
@property (nonatomic, strong) Class delegateProxy;
@property (nonatomic, strong) NSMutableSet *selectors;
- (instancetype)initWithDelegate:(id)delegate proxy:(id)proxy;
- (void)removeKVO;
@end
@interface TDDelegateProxyObject (Utils)
+ (BOOL)isKVOClass:(Class _Nullable)cls;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b66965aa8d4f84c9fbcab5bb32c159a6
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:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More