提交
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,79 @@
|
|||||||
|
import Foundation
|
||||||
|
import StoreKit
|
||||||
|
|
||||||
|
#if canImport(PurchaseConnector)
|
||||||
|
import PurchaseConnector
|
||||||
|
|
||||||
|
@available(iOS 15.0, *)
|
||||||
|
@objc
|
||||||
|
public class AFUnityStoreKit2Bridge: NSObject {
|
||||||
|
@objc
|
||||||
|
public static func fetchAFSDKTransactionSK2(withTransactionId transactionId: String, completion: @escaping (AFSDKTransactionSK2?) -> Void) {
|
||||||
|
guard let transactionIdUInt64 = UInt64(transactionId) else {
|
||||||
|
print("Invalid transaction ID format.")
|
||||||
|
completion(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Task {
|
||||||
|
for await result in StoreKit.Transaction.all {
|
||||||
|
if case .verified(let transaction) = result, transaction.id == transactionIdUInt64 {
|
||||||
|
let afTransaction = AFSDKTransactionSK2(transaction: transaction)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(afTransaction)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static func extractSK2ProductInfo(_ products: [AFSDKProductSK2]) -> NSArray {
|
||||||
|
var result: [[String: Any]] = []
|
||||||
|
|
||||||
|
for product in products {
|
||||||
|
if let swiftProduct = Mirror(reflecting: product).children.first(where: { $0.label == "product" })?.value {
|
||||||
|
let productId = (swiftProduct as? NSObject)?.value(forKey: "id") as? String ?? ""
|
||||||
|
let title = (swiftProduct as? NSObject)?.value(forKey: "displayName") as? String ?? ""
|
||||||
|
let desc = (swiftProduct as? NSObject)?.value(forKey: "description") as? String ?? ""
|
||||||
|
let price = (swiftProduct as? NSObject)?.value(forKey: "price") as? NSDecimalNumber ?? 0
|
||||||
|
|
||||||
|
result.append([
|
||||||
|
"productIdentifier": productId,
|
||||||
|
"localizedTitle": title,
|
||||||
|
"localizedDescription": desc,
|
||||||
|
"price": price
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result as NSArray
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static func extractSK2TransactionInfo(_ transactions: [AFSDKTransactionSK2]) -> NSArray {
|
||||||
|
var result: [[String: Any]] = []
|
||||||
|
|
||||||
|
for txn in transactions {
|
||||||
|
guard let mirrorChild = Mirror(reflecting: txn).children.first(where: { $0.label == "transaction" }),
|
||||||
|
let swiftTxn = mirrorChild.value as? StoreKit.Transaction else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
let transactionId = "\(swiftTxn.id)"
|
||||||
|
let date = NSNumber(value: swiftTxn.purchaseDate.timeIntervalSince1970)
|
||||||
|
|
||||||
|
result.append([
|
||||||
|
"transactionIdentifier": transactionId,
|
||||||
|
"transactionState": "verified", // or skip this line
|
||||||
|
"transactionDate": date
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
return result as NSArray
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5652805602a6b4273a6e527b00aea272
|
||||||
|
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:
|
||||||
|
VisionOS: VisionOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// AFUnityUtils.h
|
||||||
|
//
|
||||||
|
// Created by Andrii H. and Dmitry O. on 16 Oct 2023
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||||
|
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||||
|
#else
|
||||||
|
#import "AppsFlyerLib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static NSString* stringFromChar(const char *str);
|
||||||
|
static NSDictionary* dictionaryFromJson(const char *jsonString);
|
||||||
|
static const char* stringFromdictionary(NSDictionary* dictionary);
|
||||||
|
static NSArray<NSString*> *NSArrayFromCArray(int length, const char **arr);
|
||||||
|
static char* getCString(const char* string);
|
||||||
|
static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator);
|
||||||
|
static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt);
|
||||||
|
static AppsFlyerAdRevenueMediationNetworkType mediationNetworkTypeFromInt(int mediationNetwork);
|
||||||
|
static NSNumber *intFromNullableBool(const char *cStr);
|
||||||
|
static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult);
|
||||||
|
static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result);
|
||||||
|
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4b0609ff467554f2088aee1c52bf54a2
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+219
@@ -0,0 +1,219 @@
|
|||||||
|
//
|
||||||
|
// AFUnityUtils.mm
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 24/07/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AFUnityUtils.h"
|
||||||
|
|
||||||
|
static NSString* stringFromChar(const char *str) {
|
||||||
|
return str ? [NSString stringWithUTF8String:str] : nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSDictionary* dictionaryFromJson(const char *jsonString) {
|
||||||
|
if(jsonString){
|
||||||
|
NSData *jsonData = [[NSData alloc] initWithBytes:jsonString length:strlen(jsonString)];
|
||||||
|
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil];
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* stringFromdictionary(NSDictionary* dictionary) {
|
||||||
|
if(dictionary){
|
||||||
|
NSError * err;
|
||||||
|
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&err];
|
||||||
|
NSString * myString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
return [myString UTF8String];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSDictionary* dictionaryFromNSError(NSError* error) {
|
||||||
|
if(error){
|
||||||
|
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
|
||||||
|
errorDictionary[@"code"] = @(error.code);
|
||||||
|
errorDictionary[@"localizedDescription"] = error.localizedDescription ?: @"";
|
||||||
|
|
||||||
|
// Include userInfo fields for enhanced error reporting (iOS SDK 6.17.8+)
|
||||||
|
if (error.userInfo[@"error_code"]) {
|
||||||
|
errorDictionary[@"error_code"] = error.userInfo[@"error_code"];
|
||||||
|
}
|
||||||
|
if (error.userInfo[@"error_message"]) {
|
||||||
|
errorDictionary[@"error_message"] = error.userInfo[@"error_message"];
|
||||||
|
}
|
||||||
|
if (error.userInfo[@"invalid_fields"]) {
|
||||||
|
errorDictionary[@"invalid_fields"] = error.userInfo[@"invalid_fields"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NSArray<NSString*> *NSArrayFromCArray(int length, const char **arr) {
|
||||||
|
NSMutableArray<NSString *> *res = [[NSMutableArray alloc] init];
|
||||||
|
for(int i = 0; i < length; i++) {
|
||||||
|
if (arr[i]) {
|
||||||
|
[res addObject:[NSString stringWithUTF8String:arr[i]]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char* getCString(const char* string){
|
||||||
|
if (string == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* res = (char*)malloc(strlen(string) + 1);
|
||||||
|
strcpy(res, string);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator) {
|
||||||
|
|
||||||
|
NSArray* generatorKeys = @[@"channel", @"customerID", @"campaign", @"referrerName", @"referrerImageUrl", @"deeplinkPath", @"baseDeeplink", @"brandDomain"];
|
||||||
|
|
||||||
|
NSMutableDictionary* mutableDictionary = [dictionary mutableCopy];
|
||||||
|
|
||||||
|
[generator setChannel:[dictionary objectForKey: @"channel"]];
|
||||||
|
[generator setReferrerCustomerId:[dictionary objectForKey: @"customerID"]];
|
||||||
|
[generator setCampaign:[dictionary objectForKey: @"campaign"]];
|
||||||
|
[generator setReferrerName:[dictionary objectForKey: @"referrerName"]];
|
||||||
|
[generator setReferrerImageURL:[dictionary objectForKey: @"referrerImageUrl"]];
|
||||||
|
[generator setDeeplinkPath:[dictionary objectForKey: @"deeplinkPath"]];
|
||||||
|
[generator setBaseDeeplink:[dictionary objectForKey: @"baseDeeplink"]];
|
||||||
|
[generator setBrandDomain:[dictionary objectForKey: @"brandDomain"]];
|
||||||
|
|
||||||
|
|
||||||
|
[mutableDictionary removeObjectsForKeys:generatorKeys];
|
||||||
|
|
||||||
|
[generator addParameters:mutableDictionary];
|
||||||
|
|
||||||
|
return generator;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt){
|
||||||
|
|
||||||
|
EmailCryptType emailCryptType;
|
||||||
|
switch (emailCryptTypeInt){
|
||||||
|
case 1:
|
||||||
|
emailCryptType = EmailCryptTypeSHA256;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
emailCryptType = EmailCryptTypeNone;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return emailCryptType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSNumber *intFromNullableBool(const char *cStr) {
|
||||||
|
if (!cStr) return nil;
|
||||||
|
NSString *str = [NSString stringWithUTF8String:cStr];
|
||||||
|
|
||||||
|
if ([str caseInsensitiveCompare:@"true"] == NSOrderedSame) {
|
||||||
|
return @YES;
|
||||||
|
} else if ([str caseInsensitiveCompare:@"false"] == NSOrderedSame) {
|
||||||
|
return @NO;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AppsFlyerAdRevenueMediationNetworkType mediationNetworkTypeFromInt(int mediationNetworkInt){
|
||||||
|
|
||||||
|
AppsFlyerAdRevenueMediationNetworkType mediationNetworkType;
|
||||||
|
switch (mediationNetworkInt){
|
||||||
|
case 1:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeIronSource;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeApplovinMax;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeFyber;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeAppodeal;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeAdmost;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeTopon;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeTradplus;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeYandex;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeChartBoost;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeUnity;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeToponPte;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeCustom;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeCustom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mediationNetworkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult){
|
||||||
|
NSString* result;
|
||||||
|
switch (deepLinkResult){
|
||||||
|
case AFSDKDeepLinkResultStatusFound:
|
||||||
|
result = @"FOUND";
|
||||||
|
break;
|
||||||
|
case AFSDKDeepLinkResultStatusFailure:
|
||||||
|
result = @"ERROR";
|
||||||
|
break;
|
||||||
|
case AFSDKDeepLinkResultStatusNotFound:
|
||||||
|
result = @"NOT_FOUND";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = @"ERROR";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result){
|
||||||
|
NSString* res;
|
||||||
|
|
||||||
|
if (result && result.error){
|
||||||
|
if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1001) {
|
||||||
|
res = @"TIMEOUT";
|
||||||
|
} else if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1009) {
|
||||||
|
res = @"NETWORK";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res = @"UNKNOWN";
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 18a03931864e84d86bedcc99c440e060
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+164
@@ -0,0 +1,164 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyer+AppController.m
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 24/07/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
#import "UnityAppController.h"
|
||||||
|
#import "AppsFlyeriOSWrapper.h"
|
||||||
|
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||||
|
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||||
|
#else
|
||||||
|
#import "AppsFlyerLib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@implementation UnityAppController (AppsFlyerSwizzledAppController)
|
||||||
|
|
||||||
|
static BOOL didEnteredBackGround __unused;
|
||||||
|
static IMP __original_applicationDidBecomeActive_Imp __unused;
|
||||||
|
static IMP __original_applicationDidEnterBackground_Imp __unused;
|
||||||
|
static IMP __original_didReceiveRemoteNotification_Imp __unused;
|
||||||
|
static IMP __original_continueUserActivity_Imp __unused;
|
||||||
|
static IMP __original_openUrl_Imp __unused;
|
||||||
|
|
||||||
|
|
||||||
|
+ (void)load {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
|
||||||
|
#if !AFSDK_SHOULD_SWIZZLE
|
||||||
|
|
||||||
|
id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"];
|
||||||
|
BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO;
|
||||||
|
|
||||||
|
if(shouldSwizzle){
|
||||||
|
|
||||||
|
Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:));
|
||||||
|
__original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive);
|
||||||
|
|
||||||
|
Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:));
|
||||||
|
__original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground);
|
||||||
|
|
||||||
|
|
||||||
|
Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:));
|
||||||
|
__original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification);
|
||||||
|
|
||||||
|
|
||||||
|
Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:));
|
||||||
|
__original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL);
|
||||||
|
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self swizzleContinueUserActivity:[self class]];
|
||||||
|
}
|
||||||
|
#elif AFSDK_SHOULD_SWIZZLE
|
||||||
|
Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:));
|
||||||
|
__original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive);
|
||||||
|
|
||||||
|
Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:));
|
||||||
|
__original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground);
|
||||||
|
|
||||||
|
|
||||||
|
Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:));
|
||||||
|
__original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification);
|
||||||
|
|
||||||
|
|
||||||
|
Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:));
|
||||||
|
__original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL);
|
||||||
|
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self swizzleContinueUserActivity:[self class]];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void)swizzleContinueUserActivity:(Class)class {
|
||||||
|
|
||||||
|
SEL originalSelector = @selector(application:continueUserActivity:restorationHandler:);
|
||||||
|
|
||||||
|
Method defaultMethod = class_getInstanceMethod(class, originalSelector);
|
||||||
|
Method swizzledMethod = class_getInstanceMethod(class, @selector(__swizzled_continueUserActivity));
|
||||||
|
|
||||||
|
BOOL isMethodExists = !class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
|
||||||
|
|
||||||
|
if (isMethodExists) {
|
||||||
|
__original_continueUserActivity_Imp = method_setImplementation(defaultMethod, (IMP)__swizzled_continueUserActivity);
|
||||||
|
} else {
|
||||||
|
class_replaceMethod(class, originalSelector, (IMP)__swizzled_continueUserActivity, method_getTypeEncoding(swizzledMethod));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL __swizzled_continueUserActivity(id self, SEL _cmd, UIApplication* application, NSUserActivity* userActivity, void (^restorationHandler)(NSArray*)) {
|
||||||
|
NSLog(@"swizzled continueUserActivity");
|
||||||
|
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||||
|
|
||||||
|
if(__original_continueUserActivity_Imp){
|
||||||
|
return ((BOOL(*)(id, SEL, UIApplication*, NSUserActivity*, void (^)(NSArray*)))__original_continueUserActivity_Imp)(self, _cmd, application, userActivity, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void __swizzled_applicationDidBecomeActive(id self, SEL _cmd, UIApplication* launchOptions) {
|
||||||
|
NSLog(@"swizzled applicationDidBecomeActive");
|
||||||
|
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||||
|
|
||||||
|
if(didEnteredBackGround && AppsFlyeriOSWarpper.didCallStart == YES){
|
||||||
|
[[AppsFlyerLib shared] start];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(__original_applicationDidBecomeActive_Imp){
|
||||||
|
((void(*)(id,SEL, UIApplication*))__original_applicationDidBecomeActive_Imp)(self, _cmd, launchOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void __swizzled_applicationDidEnterBackground(id self, SEL _cmd, UIApplication* application) {
|
||||||
|
NSLog(@"swizzled applicationDidEnterBackground");
|
||||||
|
didEnteredBackGround = YES;
|
||||||
|
if(__original_applicationDidEnterBackground_Imp){
|
||||||
|
((void(*)(id,SEL, UIApplication*))__original_applicationDidEnterBackground_Imp)(self, _cmd, application);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL __swizzled_didReceiveRemoteNotification(id self, SEL _cmd, UIApplication* application, NSDictionary* userInfo,void (^UIBackgroundFetchResult)(void) ) {
|
||||||
|
NSLog(@"swizzled didReceiveRemoteNotification");
|
||||||
|
|
||||||
|
[[AppsFlyerLib shared] handlePushNotification:userInfo];
|
||||||
|
|
||||||
|
if(__original_didReceiveRemoteNotification_Imp){
|
||||||
|
return ((BOOL(*)(id, SEL, UIApplication*, NSDictionary*, int(UIBackgroundFetchResult)))__original_didReceiveRemoteNotification_Imp)(self, _cmd, application, userInfo, nil);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOL __swizzled_openURL(id self, SEL _cmd, UIApplication* application, NSURL* url, NSDictionary * options) {
|
||||||
|
NSLog(@"swizzled openURL");
|
||||||
|
[[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
|
||||||
|
if(__original_openUrl_Imp){
|
||||||
|
return ((BOOL(*)(id, SEL, UIApplication*, NSURL*, NSDictionary*))__original_openUrl_Imp)(self, _cmd, application, url, options);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6ae9e1f7daef2427588fab2fbf8d35d5
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+131
@@ -0,0 +1,131 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyerAppController.mm
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 30/07/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "UnityAppController.h"
|
||||||
|
#import "AppDelegateListener.h"
|
||||||
|
#import "AppsFlyeriOSWrapper.h"
|
||||||
|
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||||
|
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||||
|
#else
|
||||||
|
#import "AppsFlyerLib.h"
|
||||||
|
#endif
|
||||||
|
#import <objc/message.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Note if you would like to use method swizzeling see AppsFlyer+AppController.m
|
||||||
|
If you are using swizzeling then comment out the method that is being swizzeled in AppsFlyerAppController.mm
|
||||||
|
Only use swizzeling if there are conflicts with other plugins that needs to be resolved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@interface AppsFlyerAppController : UnityAppController <AppDelegateListener>
|
||||||
|
{
|
||||||
|
BOOL didEnteredBackGround;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AppsFlyerAppController
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
|
||||||
|
id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"];
|
||||||
|
BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO;
|
||||||
|
|
||||||
|
if(!shouldSwizzle){
|
||||||
|
UnityRegisterAppDelegateListener(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didFinishLaunching:(NSNotification*)notification {
|
||||||
|
NSLog(@"got didFinishLaunching = %@",notification.userInfo);
|
||||||
|
|
||||||
|
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||||
|
|
||||||
|
if (notification.userInfo[@"url"]) {
|
||||||
|
[self onOpenURL:notification];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)didBecomeActive:(NSNotification*)notification {
|
||||||
|
NSLog(@"got didBecomeActive(out) = %@", notification.userInfo);
|
||||||
|
if (didEnteredBackGround == YES && AppsFlyeriOSWarpper.didCallStart == YES) {
|
||||||
|
[[AppsFlyerLib shared] start];
|
||||||
|
didEnteredBackGround = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didEnterBackground:(NSNotification*)notification {
|
||||||
|
NSLog(@"got didEnterBackground = %@", notification.userInfo);
|
||||||
|
didEnteredBackGround = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
|
||||||
|
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)onOpenURL:(NSNotification*)notification {
|
||||||
|
NSLog(@"got onOpenURL = %@", notification.userInfo);
|
||||||
|
NSURL *url = notification.userInfo[@"url"];
|
||||||
|
NSString *sourceApplication = notification.userInfo[@"sourceApplication"];
|
||||||
|
|
||||||
|
if (sourceApplication == nil) {
|
||||||
|
sourceApplication = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url != nil) {
|
||||||
|
[[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didReceiveRemoteNotification:(NSNotification*)notification {
|
||||||
|
NSLog(@"got didReceiveRemoteNotification = %@", notification.userInfo);
|
||||||
|
[[AppsFlyerLib shared] handlePushNotification:notification.userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#if !(AFSDK_SHOULD_SWIZZLE)
|
||||||
|
|
||||||
|
IMPL_APP_CONTROLLER_SUBCLASS(AppsFlyerAppController)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
Note if you would not like to use IMPL_APP_CONTROLLER_SUBCLASS you can replace it with the code below.
|
||||||
|
<code>
|
||||||
|
+(void)load
|
||||||
|
{
|
||||||
|
[AppsFlyerAppController plugin];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singleton accessor.
|
||||||
|
+ (AppsFlyerAppController *)plugin
|
||||||
|
{
|
||||||
|
static AppsFlyerAppController *sharedInstance = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
|
||||||
|
sharedInstance = [[AppsFlyerAppController alloc] init];
|
||||||
|
});
|
||||||
|
|
||||||
|
return sharedInstance;
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
**/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d1497a1493b24fecaa58bd3a7b707f9
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyerAttribution.h
|
||||||
|
// UnityFramework
|
||||||
|
//
|
||||||
|
// Created by Margot Guetta on 11/04/2021.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef AppsFlyerAttribution_h
|
||||||
|
#define AppsFlyerAttribution_h
|
||||||
|
#endif /* AppsFlyerAttribution_h */
|
||||||
|
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||||
|
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||||
|
#else
|
||||||
|
#import "AppsFlyerLib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@interface AppsFlyerAttribution : NSObject
|
||||||
|
@property NSUserActivity*_Nullable userActivity;
|
||||||
|
@property (nonatomic, copy) void (^ _Nullable restorationHandler)(NSArray *_Nullable );
|
||||||
|
@property NSURL * _Nullable url;
|
||||||
|
@property NSDictionary * _Nullable options;
|
||||||
|
@property NSString* _Nullable sourceApplication;
|
||||||
|
@property id _Nullable annotation;
|
||||||
|
@property BOOL isBridgeReady;
|
||||||
|
|
||||||
|
+ (AppsFlyerAttribution *_Nullable)shared;
|
||||||
|
- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler;
|
||||||
|
- (void) handleOpenUrl:(NSURL*_Nullable)url options:(NSDictionary*_Nullable) options;
|
||||||
|
- (void) handleOpenUrl: (NSURL *_Nonnull)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
static NSString * _Nullable const AF_BRIDGE_SET = @"bridge is set";
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8544dc3b3c7bb40d397b2de568df1058
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
//
|
||||||
|
// NSObject+AppsFlyerAttribution.m
|
||||||
|
// UnityFramework
|
||||||
|
//
|
||||||
|
// Created by Margot Guetta on 11/04/2021.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AppsFlyerAttribution.h"
|
||||||
|
|
||||||
|
@implementation AppsFlyerAttribution
|
||||||
|
|
||||||
|
+ (id)shared {
|
||||||
|
static AppsFlyerAttribution *shared = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
shared = [[self alloc] init];
|
||||||
|
});
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.options = nil;
|
||||||
|
self.restorationHandler = nil;
|
||||||
|
self.url = nil;
|
||||||
|
self.userActivity = nil;
|
||||||
|
self.annotation = nil;
|
||||||
|
self.sourceApplication = nil;
|
||||||
|
self.isBridgeReady = NO;
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(receiveBridgeReadyNotification:)
|
||||||
|
name:AF_BRIDGE_SET
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler{
|
||||||
|
if(self.isBridgeReady == YES){
|
||||||
|
[[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
|
||||||
|
}else{
|
||||||
|
[AppsFlyerAttribution shared].userActivity = userActivity;
|
||||||
|
[AppsFlyerAttribution shared].restorationHandler = restorationHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) handleOpenUrl:(NSURL *)url options:(NSDictionary *)options{
|
||||||
|
if(self.isBridgeReady == YES){
|
||||||
|
[[AppsFlyerLib shared] handleOpenUrl:url options:options];
|
||||||
|
}else{
|
||||||
|
[AppsFlyerAttribution shared].url = url;
|
||||||
|
[AppsFlyerAttribution shared].options = options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) handleOpenUrl:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation{
|
||||||
|
if(self.isBridgeReady == YES){
|
||||||
|
[[AppsFlyerLib shared] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation];
|
||||||
|
}else{
|
||||||
|
[AppsFlyerAttribution shared].url = url;
|
||||||
|
[AppsFlyerAttribution shared].sourceApplication = sourceApplication;
|
||||||
|
[AppsFlyerAttribution shared].annotation = annotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) receiveBridgeReadyNotification:(NSNotification *) notification
|
||||||
|
{
|
||||||
|
NSLog (@"AppsFlyer Debug: handle deep link");
|
||||||
|
if(self.url && self.sourceApplication){
|
||||||
|
[[AppsFlyerLib shared] handleOpenURL:self.url sourceApplication:self.sourceApplication withAnnotation:self.annotation];
|
||||||
|
self.url = nil;
|
||||||
|
self.sourceApplication = nil;
|
||||||
|
self.annotation = nil;
|
||||||
|
}else if(self.options && self.url){
|
||||||
|
[[AppsFlyerLib shared] handleOpenUrl:self.url options:self.options];
|
||||||
|
self.options = nil;
|
||||||
|
self.url = nil;
|
||||||
|
}else if(self.userActivity){
|
||||||
|
[[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:nil];
|
||||||
|
self.userActivity = nil;
|
||||||
|
self.restorationHandler = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1060e47d7b9e2453ba575f0b455b2bf8
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyeriOSWarpper.h
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 24/07/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AFUnityUtils.mm"
|
||||||
|
#import "UnityAppController.h"
|
||||||
|
#import "AppsFlyerAttribution.h"
|
||||||
|
#if __has_include(<AppsFlyerLib/AppsFlyerLib.h>)
|
||||||
|
#import <AppsFlyerLib/AppsFlyerLib.h>
|
||||||
|
#else
|
||||||
|
#import "AppsFlyerLib.h"
|
||||||
|
#endif
|
||||||
|
#if __has_include(<PurchaseConnector/PurchaseConnector.h>)
|
||||||
|
#import <PurchaseConnector/PurchaseConnector.h>
|
||||||
|
#else
|
||||||
|
#import "PurchaseConnector.h"
|
||||||
|
#endif
|
||||||
|
#import <PurchaseConnector/PurchaseConnector-Swift.h>
|
||||||
|
|
||||||
|
// Add StoreKit 2 support
|
||||||
|
#if __has_include(<StoreKit/StoreKit.h>)
|
||||||
|
#import <StoreKit/StoreKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface AppsFlyeriOSWarpper : NSObject <AppsFlyerLibDelegate, AppsFlyerDeepLinkDelegate, AppsFlyerPurchaseRevenueDelegate, AppsFlyerPurchaseRevenueDataSource, AppsFlyerPurchaseRevenueDataSourceStoreKit2>
|
||||||
|
|
||||||
|
+ (BOOL) didCallStart;
|
||||||
|
+ (void) setDidCallStart:(BOOL)val;
|
||||||
|
|
||||||
|
// Add StoreKit 2 methods
|
||||||
|
- (void)setStoreKitVersion:(int)storeKitVersion;
|
||||||
|
- (void)logConsumableTransaction:(id)transaction;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
static AppsFlyeriOSWarpper *_AppsFlyerdelegate;
|
||||||
|
static const int kPushNotificationSize = 32;
|
||||||
|
|
||||||
|
static NSString* ConversionDataCallbackObject = @"AppsFlyerObject";
|
||||||
|
|
||||||
|
static const char* VALIDATE_CALLBACK = "didFinishValidateReceipt";
|
||||||
|
static const char* VALIDATE_ERROR_CALLBACK = "didFinishValidateReceiptWithError";
|
||||||
|
static const char* GCD_CALLBACK = "onConversionDataSuccess";
|
||||||
|
static const char* GCD_ERROR_CALLBACK = "onConversionDataFail";
|
||||||
|
static const char* OAOA_CALLBACK = "onAppOpenAttribution";
|
||||||
|
static const char* OAOA_ERROR_CALLBACK = "onAppOpenAttributionFailure";
|
||||||
|
static const char* GENERATE_LINK_CALLBACK = "onInviteLinkGenerated";
|
||||||
|
static const char* OPEN_STORE_LINK_CALLBACK = "onOpenStoreLinkGenerated";
|
||||||
|
static const char* START_REQUEST_CALLBACK = "requestResponseReceived";
|
||||||
|
static const char* IN_APP_RESPONSE_CALLBACK = "inAppResponseReceived";
|
||||||
|
static const char* ON_DEEPLINKING = "onDeepLinking";
|
||||||
|
static const char* VALIDATE_AND_LOG_V2_CALLBACK = "onValidateAndLogComplete";
|
||||||
|
static const char* VALIDATE_AND_LOG_V2_ERROR_CALLBACK = "onValidateAndLogFailure";
|
||||||
|
|
||||||
|
|
||||||
|
static NSString* validateObjectName = @"";
|
||||||
|
static NSString* openStoreObjectName = @"";
|
||||||
|
static NSString* generateInviteObjectName = @"";
|
||||||
|
static NSString* validateAndLogObjectName = @"";
|
||||||
|
static NSString* startRequestObjectName = @"";
|
||||||
|
static NSString* inAppRequestObjectName = @"";
|
||||||
|
static NSString* onDeeplinkingObjectName = @"";
|
||||||
|
|
||||||
|
static const char* PURCHASE_REVENUE_VALIDATION_CALLBACK = "didReceivePurchaseRevenueValidationInfo";
|
||||||
|
static const char* PURCHASE_REVENUE_ERROR_CALLBACK = "didReceivePurchaseRevenueError";
|
||||||
|
|
||||||
|
static NSString* onPurchaseValidationObjectName = @"";
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 147104b04b5794eaa92b4195cc328e13
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+601
@@ -0,0 +1,601 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyeriOSWarpper.mm
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 24/07/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AppsFlyeriOSWrapper.h"
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
|
#import <StoreKit/StoreKit.h>
|
||||||
|
#import "UnityFramework/UnityFramework-Swift.h"
|
||||||
|
|
||||||
|
#if __has_include(<PurchaseConnector/PurchaseConnector-Swift.h>)
|
||||||
|
#import <PurchaseConnector/PurchaseConnector-Swift.h>
|
||||||
|
#elif __has_include("PurchaseConnector-Swift.h")
|
||||||
|
#import "PurchaseConnector-Swift.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_include(<UnityFramework/UnityFramework-Swift.h>)
|
||||||
|
#import <UnityFramework/UnityFramework-Swift.h>
|
||||||
|
#elif __has_include("UnityFramework-Swift.h")
|
||||||
|
#import "UnityFramework-Swift.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void unityCallBack(NSString* objectName, const char* method, const char* msg) {
|
||||||
|
if(objectName){
|
||||||
|
UnitySendMessage([objectName UTF8String], method, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
const void _startSDK(bool shouldCallback, const char* objectName) {
|
||||||
|
[[AppsFlyerLib shared] setPluginInfoWith: AFSDKPluginUnity
|
||||||
|
pluginVersion:@"6.17.91"
|
||||||
|
additionalParams:nil];
|
||||||
|
startRequestObjectName = stringFromChar(objectName);
|
||||||
|
AppsFlyeriOSWarpper.didCallStart = YES;
|
||||||
|
[AppsFlyerAttribution shared].isBridgeReady = YES;
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:AF_BRIDGE_SET object: [AppsFlyerAttribution shared]];
|
||||||
|
[[AppsFlyerLib shared] startWithCompletionHandler:^(NSDictionary<NSString *,id> *dictionary, NSError *error) {
|
||||||
|
if(shouldCallback){
|
||||||
|
if (error) {
|
||||||
|
NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]};
|
||||||
|
unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(callbackDictionary));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dictionary) {
|
||||||
|
unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(dictionary));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setCustomerUserID (const char* customerUserID) {
|
||||||
|
[[AppsFlyerLib shared] setCustomerUserID:stringFromChar(customerUserID)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setAdditionalData (const char* customData) {
|
||||||
|
[[AppsFlyerLib shared] setAdditionalData:dictionaryFromJson(customData)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setAppsFlyerDevKey (const char* appsFlyerDevKey) {
|
||||||
|
[AppsFlyerLib shared].appsFlyerDevKey = stringFromChar(appsFlyerDevKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setAppleAppID (const char* appleAppID) {
|
||||||
|
[AppsFlyerLib shared].appleAppID = stringFromChar(appleAppID);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setCurrencyCode (const char* currencyCode) {
|
||||||
|
[[AppsFlyerLib shared] setCurrencyCode:stringFromChar(currencyCode)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setDisableCollectAppleAdSupport (bool disableAdvertisingIdentifier) {
|
||||||
|
[AppsFlyerLib shared].disableAdvertisingIdentifier = disableAdvertisingIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setIsDebug (bool isDebug) {
|
||||||
|
[AppsFlyerLib shared].isDebug = isDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setShouldCollectDeviceName (bool shouldCollectDeviceName) {
|
||||||
|
[AppsFlyerLib shared].shouldCollectDeviceName = shouldCollectDeviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setAppInviteOneLinkID (const char* appInviteOneLinkID) {
|
||||||
|
[[AppsFlyerLib shared] setAppInviteOneLink:stringFromChar(appInviteOneLinkID)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setDeepLinkTimeout (long deepLinkTimeout) {
|
||||||
|
[AppsFlyerLib shared].deepLinkTimeout = deepLinkTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _anonymizeUser (bool anonymizeUser) {
|
||||||
|
[AppsFlyerLib shared].anonymizeUser = anonymizeUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _enableTCFDataCollection (bool shouldCollectTcfData) {
|
||||||
|
[[AppsFlyerLib shared] enableTCFDataCollection:shouldCollectTcfData];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setConsentData(const char* isUserSubjectToGDPR, const char* hasConsentForDataUsage, const char* hasConsentForAdsPersonalization, const char* hasConsentForAdStorage) {
|
||||||
|
|
||||||
|
NSNumber *gdpr = intFromNullableBool(isUserSubjectToGDPR);
|
||||||
|
NSNumber *dataUsage = intFromNullableBool(hasConsentForDataUsage);
|
||||||
|
NSNumber *adsPersonalization = intFromNullableBool(hasConsentForAdsPersonalization);
|
||||||
|
NSNumber *adStorage = intFromNullableBool(hasConsentForAdStorage);
|
||||||
|
|
||||||
|
AppsFlyerConsent *consentData = [[AppsFlyerConsent alloc] initWithIsUserSubjectToGDPR:gdpr
|
||||||
|
hasConsentForDataUsage:dataUsage
|
||||||
|
hasConsentForAdsPersonalization:adsPersonalization
|
||||||
|
hasConsentForAdStorage:adStorage];
|
||||||
|
|
||||||
|
[[AppsFlyerLib shared] setConsentData:consentData];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _logAdRevenue(const char* monetizationNetwork, int mediationNetworkInt, const char* currencyIso4217Code, double eventRevenue, const char* additionalParameters) {
|
||||||
|
AppsFlyerAdRevenueMediationNetworkType mediationNetwork = mediationNetworkTypeFromInt(mediationNetworkInt);
|
||||||
|
NSNumber *number = [NSNumber numberWithDouble:eventRevenue];
|
||||||
|
AFAdRevenueData *adRevenue = [[AFAdRevenueData alloc] initWithMonetizationNetwork:stringFromChar(monetizationNetwork) mediationNetwork:mediationNetwork currencyIso4217Code:stringFromChar(currencyIso4217Code) eventRevenue:number];
|
||||||
|
[[AppsFlyerLib shared] logAdRevenue: adRevenue additionalParameters:dictionaryFromJson(additionalParameters)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setDisableCollectIAd (bool disableCollectASA) {
|
||||||
|
[AppsFlyerLib shared].disableCollectASA = disableCollectASA;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setUseReceiptValidationSandbox (bool useReceiptValidationSandbox) {
|
||||||
|
[AppsFlyerLib shared].useReceiptValidationSandbox = useReceiptValidationSandbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setUseUninstallSandbox (bool useUninstallSandbox) {
|
||||||
|
[AppsFlyerLib shared].useUninstallSandbox = useUninstallSandbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setResolveDeepLinkURLs (int length, const char **resolveDeepLinkURLs) {
|
||||||
|
if(length > 0 && resolveDeepLinkURLs) {
|
||||||
|
[[AppsFlyerLib shared] setResolveDeepLinkURLs:NSArrayFromCArray(length, resolveDeepLinkURLs)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setOneLinkCustomDomains (int length, const char **oneLinkCustomDomains) {
|
||||||
|
if(length > 0 && oneLinkCustomDomains) {
|
||||||
|
[[AppsFlyerLib shared] setOneLinkCustomDomains:NSArrayFromCArray(length, oneLinkCustomDomains)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _afSendEvent (const char* eventName, const char* eventValues, bool shouldCallback, const char* objectName) {
|
||||||
|
inAppRequestObjectName = stringFromChar(objectName);
|
||||||
|
[[AppsFlyerLib shared] logEventWithEventName:stringFromChar(eventName) eventValues:dictionaryFromJson(eventValues) completionHandler:^(NSDictionary<NSString *,id> *dictionary, NSError *error) {
|
||||||
|
if(shouldCallback){
|
||||||
|
if (error) {
|
||||||
|
NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]};
|
||||||
|
unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(callbackDictionary));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dictionary) {
|
||||||
|
unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(dictionary));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _recordLocation (double longitude, double latitude) {
|
||||||
|
[[AppsFlyerLib shared] logLocation:longitude latitude:latitude];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* _getAppsFlyerId () {
|
||||||
|
return getCString([[[AppsFlyerLib shared] getAppsFlyerUID] UTF8String]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _registerUninstall (unsigned char* deviceToken) {
|
||||||
|
if(deviceToken){
|
||||||
|
NSData* tokenData = [NSData dataWithBytes:(const void *)deviceToken length:sizeof(unsigned char)*kPushNotificationSize];
|
||||||
|
[[AppsFlyerLib shared] registerUninstall:tokenData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _handlePushNotification (const char* pushPayload) {
|
||||||
|
[[AppsFlyerLib shared] handlePushNotification:dictionaryFromJson(pushPayload)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* _getSDKVersion () {
|
||||||
|
return getCString([[[AppsFlyerLib shared] getSDKVersion] UTF8String]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setHost (const char* host, const char* hostPrefix) {
|
||||||
|
[[AppsFlyerLib shared] setHost:stringFromChar(host) withHostPrefix:stringFromChar(hostPrefix)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setMinTimeBetweenSessions (int minTimeBetweenSessions) {
|
||||||
|
[AppsFlyerLib shared].minTimeBetweenSessions = minTimeBetweenSessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _stopSDK (bool isStopped) {
|
||||||
|
[AppsFlyerLib shared].isStopped = isStopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BOOL _isSDKStopped () {
|
||||||
|
return [AppsFlyerLib shared].isStopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _handleOpenUrl(const char *url, const char *sourceApplication, const char *annotation) {
|
||||||
|
[[AppsFlyerLib shared] handleOpenURL:[NSURL URLWithString:stringFromChar(url)] sourceApplication:stringFromChar(sourceApplication) withAnnotation:stringFromChar(annotation)]; }
|
||||||
|
|
||||||
|
const void _recordCrossPromoteImpression (const char* appID, const char* campaign, const char* parameters) {
|
||||||
|
[AppsFlyerCrossPromotionHelper logCrossPromoteImpression:stringFromChar(appID) campaign:stringFromChar(campaign) parameters:dictionaryFromJson(parameters)]; }
|
||||||
|
|
||||||
|
const void _attributeAndOpenStore (const char* appID, const char* campaign, const char* parameters, const char* objectName) {
|
||||||
|
|
||||||
|
openStoreObjectName = stringFromChar(objectName);
|
||||||
|
|
||||||
|
[AppsFlyerCrossPromotionHelper
|
||||||
|
logAndOpenStore:stringFromChar(appID)
|
||||||
|
campaign:stringFromChar(campaign)
|
||||||
|
parameters:dictionaryFromJson(parameters)
|
||||||
|
openStore:^(NSURLSession * _Nonnull urlSession, NSURL * _Nonnull clickURL) {
|
||||||
|
unityCallBack(openStoreObjectName, OPEN_STORE_LINK_CALLBACK, [clickURL.absoluteString UTF8String]);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _generateUserInviteLink (const char* parameters, const char* objectName) {
|
||||||
|
|
||||||
|
generateInviteObjectName = stringFromChar(objectName);
|
||||||
|
|
||||||
|
[AppsFlyerShareInviteHelper generateInviteUrlWithLinkGenerator:^AppsFlyerLinkGenerator * _Nonnull(AppsFlyerLinkGenerator * _Nonnull generator) {
|
||||||
|
return generatorFromDictionary(dictionaryFromJson(parameters), generator);
|
||||||
|
} completionHandler:^(NSURL * _Nullable url) {
|
||||||
|
unityCallBack(generateInviteObjectName, GENERATE_LINK_CALLBACK, [url.absoluteString UTF8String]);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _recordInvite (const char* channel, const char* parameters) {
|
||||||
|
[AppsFlyerShareInviteHelper logInvite:stringFromChar(channel) parameters:dictionaryFromJson(parameters)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setUserEmails (int emailCryptTypeInt , int length, const char **userEmails) {
|
||||||
|
if(length > 0 && userEmails) {
|
||||||
|
[[AppsFlyerLib shared] setUserEmails:NSArrayFromCArray(length, userEmails) withCryptType:emailCryptTypeFromInt(emailCryptTypeInt)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setPhoneNumber (const char* phoneNumber) {
|
||||||
|
[[AppsFlyerLib shared] setPhoneNumber:stringFromChar(phoneNumber)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setSharingFilterForAllPartners () {
|
||||||
|
[[AppsFlyerLib shared] setSharingFilterForAllPartners];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setSharingFilter (int length, const char **partners) {
|
||||||
|
if(length > 0 && partners) {
|
||||||
|
[[AppsFlyerLib shared] setSharingFilter:NSArrayFromCArray(length, partners)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setSharingFilterForPartners (int length, const char **partners) {
|
||||||
|
if(length > 0 && partners) {
|
||||||
|
[[AppsFlyerLib shared] setSharingFilterForPartners:NSArrayFromCArray(length, partners)];
|
||||||
|
} else {
|
||||||
|
[[AppsFlyerLib shared] setSharingFilterForPartners:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _validateAndSendInAppPurchase (const char* productIdentifier, const char* price, const char* currency, const char* transactionId, const char* additionalParameters, const char* objectName) {
|
||||||
|
|
||||||
|
validateObjectName = stringFromChar(objectName);
|
||||||
|
|
||||||
|
[[AppsFlyerLib shared]
|
||||||
|
validateAndLogInAppPurchase:stringFromChar(productIdentifier)
|
||||||
|
price:stringFromChar(price)
|
||||||
|
currency:stringFromChar(currency)
|
||||||
|
transactionId:stringFromChar(transactionId)
|
||||||
|
additionalParameters:dictionaryFromJson(additionalParameters)
|
||||||
|
success:^(NSDictionary *result){
|
||||||
|
unityCallBack(validateObjectName, VALIDATE_CALLBACK, stringFromdictionary(result));
|
||||||
|
} failure:^(NSError *error, id response) {
|
||||||
|
if(response && [response isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSDictionary* value = (NSDictionary*)response;
|
||||||
|
unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, stringFromdictionary(value));
|
||||||
|
} else {
|
||||||
|
unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, error ? [[error localizedDescription] UTF8String] : "error");
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _validateAndSendInAppPurchaseV2 (const char* product, const char* transactionId, int purchaseType, const char* purchaseAdditionalDetails, const char* objectName) {
|
||||||
|
|
||||||
|
validateAndLogObjectName = stringFromChar(objectName);
|
||||||
|
AFSDKPurchaseDetails *details = [[AFSDKPurchaseDetails alloc] initWithProductId:stringFromChar(product) transactionId:stringFromChar(transactionId) purchaseType:(AFSDKPurchaseType)purchaseType];
|
||||||
|
|
||||||
|
[[AppsFlyerLib shared]
|
||||||
|
validateAndLogInAppPurchase:details
|
||||||
|
purchaseAdditionalDetails:dictionaryFromJson(purchaseAdditionalDetails)
|
||||||
|
completion:^(NSDictionary * _Nullable response, NSError * _Nullable error) {
|
||||||
|
if (error) {
|
||||||
|
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_ERROR_CALLBACK, stringFromdictionary(dictionaryFromNSError(error)));
|
||||||
|
} else {
|
||||||
|
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(response));
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _getConversionData(const char* objectName) {
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
ConversionDataCallbackObject = stringFromChar(objectName);
|
||||||
|
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _waitForATTUserAuthorizationWithTimeoutInterval (int timeoutInterval) {
|
||||||
|
[[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:timeoutInterval];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _disableSKAdNetwork (bool isDisabled) {
|
||||||
|
[AppsFlyerLib shared].disableSKAdNetwork = isDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _addPushNotificationDeepLinkPath (int length, const char **paths) {
|
||||||
|
if(length > 0 && paths) {
|
||||||
|
[[AppsFlyerLib shared] addPushNotificationDeepLinkPath:NSArrayFromCArray(length, paths)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _subscribeForDeepLink (const char* objectName) {
|
||||||
|
|
||||||
|
onDeeplinkingObjectName = stringFromChar(objectName);
|
||||||
|
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
[[AppsFlyerLib shared] setDeepLinkDelegate:_AppsFlyerdelegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setCurrentDeviceLanguage(const char* language) {
|
||||||
|
[[AppsFlyerLib shared] setCurrentDeviceLanguage:stringFromChar(language)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setPartnerData(const char* partnerId, const char* partnerInfo) {
|
||||||
|
[[AppsFlyerLib shared] setPartnerDataWithPartnerId: stringFromChar(partnerId) partnerInfo:dictionaryFromJson(partnerInfo)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _disableIDFVCollection(bool isDisabled) {
|
||||||
|
[AppsFlyerLib shared].disableIDFVCollection = isDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purchase connector
|
||||||
|
const void _startObservingTransactions() {
|
||||||
|
[[PurchaseConnector shared] startObservingTransactions];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _stopObservingTransactions() {
|
||||||
|
[[PurchaseConnector shared] stopObservingTransactions];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setIsSandbox(bool isSandBox) {
|
||||||
|
[[PurchaseConnector shared] setIsSandbox:isSandBox];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setPurchaseRevenueDelegate() {
|
||||||
|
if (_AppsFlyerdelegate== nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
[[PurchaseConnector shared] setPurchaseRevenueDelegate:_AppsFlyerdelegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setAutoLogPurchaseRevenue(int option) {
|
||||||
|
[[PurchaseConnector shared] setAutoLogPurchaseRevenue:option];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _initPurchaseConnector(const char* objectName) {
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
onPurchaseValidationObjectName = stringFromChar(objectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setPurchaseRevenueDataSource(const char* objectName) {
|
||||||
|
if (_AppsFlyerdelegate == nil) {
|
||||||
|
_AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strstr(objectName, "StoreKit2") != NULL) {
|
||||||
|
|
||||||
|
// Force protocol conformance
|
||||||
|
Protocol *sk2Protocol = @protocol(AppsFlyerPurchaseRevenueDataSourceStoreKit2);
|
||||||
|
class_addProtocol([_AppsFlyerdelegate class], sk2Protocol);
|
||||||
|
|
||||||
|
if (![_AppsFlyerdelegate conformsToProtocol:@protocol(AppsFlyerPurchaseRevenueDataSourceStoreKit2)]) {
|
||||||
|
NSLog(@"[AppsFlyer] Warning: SK2 protocol not conformed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[PurchaseConnector shared].purchaseRevenueDataSource = _AppsFlyerdelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _setStoreKitVersion(int storeKitVersion) {
|
||||||
|
[[PurchaseConnector shared] setStoreKitVersion:(AFSDKStoreKitVersion)storeKitVersion];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _logConsumableTransaction(const char* transactionId) {
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
NSString *transactionIdStr = [NSString stringWithUTF8String:transactionId];
|
||||||
|
[AFUnityStoreKit2Bridge fetchAFSDKTransactionSK2WithTransactionId:transactionIdStr completion:^(AFSDKTransactionSK2 *afTransaction) {
|
||||||
|
if (afTransaction) {
|
||||||
|
[[PurchaseConnector shared] logConsumableTransaction:afTransaction];
|
||||||
|
} else {
|
||||||
|
NSLog(@"No AFSDKTransactionSK2 found for id %@", transactionIdStr);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef const char *(*UnityPurchaseCallback)(const char *, const char *);
|
||||||
|
|
||||||
|
UnityPurchaseCallback UnityPurchasesGetAdditionalParamsCallback = NULL;
|
||||||
|
UnityPurchaseCallback UnityPurchasesGetAdditionalParamsCallbackSK2 = NULL;
|
||||||
|
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
void RegisterUnityPurchaseRevenueParamsCallback(UnityPurchaseCallback callback) {
|
||||||
|
UnityPurchasesGetAdditionalParamsCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
void RegisterUnityPurchaseRevenueParamsCallbackSK2(UnityPurchaseCallback callback) {
|
||||||
|
UnityPurchasesGetAdditionalParamsCallbackSK2 = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation AppsFlyeriOSWarpper
|
||||||
|
|
||||||
|
static BOOL didCallStart;
|
||||||
|
+ (BOOL) didCallStart
|
||||||
|
{ @synchronized(self) { return didCallStart; } }
|
||||||
|
+ (void) setDidCallStart:(BOOL)val
|
||||||
|
{ @synchronized(self) { didCallStart = val; } }
|
||||||
|
|
||||||
|
- (void)onConversionDataSuccess:(NSDictionary *)installData {
|
||||||
|
unityCallBack(ConversionDataCallbackObject, GCD_CALLBACK, stringFromdictionary(installData));
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onConversionDataFail:(NSError *)error {
|
||||||
|
unityCallBack(ConversionDataCallbackObject, GCD_ERROR_CALLBACK, [[error localizedDescription] UTF8String]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onAppOpenAttribution:(NSDictionary *)attributionData {
|
||||||
|
unityCallBack(ConversionDataCallbackObject, OAOA_CALLBACK, stringFromdictionary(attributionData));
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onAppOpenAttributionFailure:(NSError *)error {
|
||||||
|
unityCallBack(ConversionDataCallbackObject, OAOA_ERROR_CALLBACK, [[error localizedDescription] UTF8String]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didResolveDeepLink:(AppsFlyerDeepLinkResult *)result{
|
||||||
|
|
||||||
|
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
[dict setValue:stringFromDeepLinkResultError(result) forKey:@"error"];
|
||||||
|
[dict setValue:stringFromDeepLinkResultStatus(result.status) forKey:@"status"];
|
||||||
|
|
||||||
|
if(result && result.deepLink){
|
||||||
|
[dict setValue:result.deepLink.description forKey:@"deepLink"];
|
||||||
|
[dict setValue:@(result.deepLink.isDeferred) forKey:@"is_deferred"];
|
||||||
|
}
|
||||||
|
|
||||||
|
unityCallBack(onDeeplinkingObjectName, ON_DEEPLINKING, stringFromdictionary(dict));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purchase Connector
|
||||||
|
- (void)didReceivePurchaseRevenueValidationInfo:(NSDictionary *)validationInfo error:(NSError *)error {
|
||||||
|
if (error != nil) {
|
||||||
|
unityCallBack(onPurchaseValidationObjectName, PURCHASE_REVENUE_ERROR_CALLBACK, [[error localizedDescription] UTF8String]);
|
||||||
|
} else {
|
||||||
|
unityCallBack(onPurchaseValidationObjectName, PURCHASE_REVENUE_VALIDATION_CALLBACK, stringFromdictionary(validationInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)purchaseRevenueAdditionalParametersForProducts:(NSSet<SKProduct *> *)products
|
||||||
|
transactions:(NSSet<SKPaymentTransaction *> *)transactions {
|
||||||
|
|
||||||
|
NSMutableArray *productsArray = [NSMutableArray array];
|
||||||
|
for (SKProduct *product in products) {
|
||||||
|
[productsArray addObject:@{
|
||||||
|
@"productIdentifier": product.productIdentifier ?: @"",
|
||||||
|
@"localizedTitle": product.localizedTitle ?: @"",
|
||||||
|
@"localizedDescription": product.localizedDescription ?: @"",
|
||||||
|
@"price": [product.price stringValue] ?: @""
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *transactionsArray = [NSMutableArray array];
|
||||||
|
for (SKPaymentTransaction *txn in transactions) {
|
||||||
|
[transactionsArray addObject:@{
|
||||||
|
@"transactionIdentifier": txn.transactionIdentifier ?: @"",
|
||||||
|
@"transactionState": @(txn.transactionState),
|
||||||
|
@"transactionDate": txn.transactionDate ? [@(txn.transactionDate.timeIntervalSince1970) stringValue] : @""
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *input = @{
|
||||||
|
@"products": productsArray,
|
||||||
|
@"transactions": transactionsArray
|
||||||
|
};
|
||||||
|
|
||||||
|
NSError *error = nil;
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:input options:0 error:&error];
|
||||||
|
if (error || !jsonData) {
|
||||||
|
NSLog(@"[AppsFlyer] Failed to serialize Unity purchase data: %@", error);
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
if (!jsonString || !UnityPurchasesGetAdditionalParamsCallback) {
|
||||||
|
NSLog(@"[AppsFlyer] Unity callback not registered");
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *resultCStr = UnityPurchasesGetAdditionalParamsCallback([jsonString UTF8String], "");
|
||||||
|
if (!resultCStr) {
|
||||||
|
NSLog(@"[AppsFlyer] Unity callback returned null");
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *resultJson = [NSString stringWithUTF8String:resultCStr];
|
||||||
|
NSData *resultData = [resultJson dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
NSDictionary *parsedResult = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&error];
|
||||||
|
|
||||||
|
if (error || ![parsedResult isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSLog(@"[AppsFlyer] Failed to parse Unity response: %@", error);
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AppsFlyerPurchaseRevenueDataSourceStoreKit2
|
||||||
|
- (NSDictionary *)purchaseRevenueAdditionalParametersStoreKit2ForProducts:(NSSet<AFSDKProductSK2 *> *)products transactions:(NSSet<AFSDKTransactionSK2 *> *)transactions {
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
NSArray *productInfoArray = [AFUnityStoreKit2Bridge extractSK2ProductInfo:[products allObjects]];
|
||||||
|
NSArray *transactionInfoArray = [AFUnityStoreKit2Bridge extractSK2TransactionInfo:[transactions allObjects]];
|
||||||
|
|
||||||
|
NSDictionary *input = @{
|
||||||
|
@"products": productInfoArray,
|
||||||
|
@"transactions": transactionInfoArray
|
||||||
|
};
|
||||||
|
|
||||||
|
if (UnityPurchasesGetAdditionalParamsCallbackSK2) {
|
||||||
|
NSError *error = nil;
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:input options:0 error:&error];
|
||||||
|
if (error || !jsonData) {
|
||||||
|
NSLog(@"[AppsFlyer] Failed to serialize Unity purchase data: %@", error);
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
const char *resultCStr = UnityPurchasesGetAdditionalParamsCallbackSK2([jsonString UTF8String], "");
|
||||||
|
if (!resultCStr) {
|
||||||
|
NSLog(@"[AppsFlyer] Unity callback returned null");
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *resultJson = [NSString stringWithUTF8String:resultCStr];
|
||||||
|
|
||||||
|
NSData *resultData = [resultJson dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
NSDictionary *parsedResult = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&error];
|
||||||
|
|
||||||
|
if (error || ![parsedResult isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSLog(@"[AppsFlyer] Failed to parse Unity response: %@", error);
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedResult;
|
||||||
|
} else {
|
||||||
|
NSLog(@"[AppsFlyer] SK2 - Unity callback is NOT registered");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NSLog(@"[AppsFlyer] SK2 - iOS version not supported");
|
||||||
|
}
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bff3788f3d8747fe9679bd3818e1d76
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Regular → Executable
+145
-145
@@ -1,145 +1,145 @@
|
|||||||
//#define AFSDK_WIN_DEBUG
|
//#define AFSDK_WIN_DEBUG
|
||||||
//#define UNITY_WSA_10_0
|
//#define UNITY_WSA_10_0
|
||||||
//#define ENABLE_WINMD_SUPPORT
|
//#define ENABLE_WINMD_SUPPORT
|
||||||
|
|
||||||
#if UNITY_WSA_10_0
|
#if UNITY_WSA_10_0
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
using AppsFlyerLib;
|
using AppsFlyerLib;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace AppsFlyerSDK
|
namespace AppsFlyerSDK
|
||||||
{
|
{
|
||||||
public class AppsFlyerWindows
|
public class AppsFlyerWindows
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
static private MonoBehaviour _gameObject = null;
|
static private MonoBehaviour _gameObject = null;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static void InitSDK(string devKey, string appId, MonoBehaviour gameObject)
|
public static void InitSDK(string devKey, string appId, MonoBehaviour gameObject)
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
|
|
||||||
#if AFSDK_WIN_DEBUG
|
#if AFSDK_WIN_DEBUG
|
||||||
// Remove callstack
|
// Remove callstack
|
||||||
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
|
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
|
||||||
#endif
|
#endif
|
||||||
Log("[InitSDK]: devKey: {0}, appId: {1}, gameObject: {2}", devKey, appId, gameObject == null ? "null" : gameObject.ToString());
|
Log("[InitSDK]: devKey: {0}, appId: {1}, gameObject: {2}", devKey, appId, gameObject == null ? "null" : gameObject.ToString());
|
||||||
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
|
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
|
||||||
tracker.devKey = devKey;
|
tracker.devKey = devKey;
|
||||||
tracker.appId = appId;
|
tracker.appId = appId;
|
||||||
// Interface
|
// Interface
|
||||||
_gameObject = gameObject;
|
_gameObject = gameObject;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAppsFlyerId()
|
public static string GetAppsFlyerId()
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
Log("[GetAppsFlyerId]");
|
Log("[GetAppsFlyerId]");
|
||||||
return AppsFlyerTracker.GetAppsFlyerTracker().GetAppsFlyerUID();
|
return AppsFlyerTracker.GetAppsFlyerTracker().GetAppsFlyerUID();
|
||||||
#else
|
#else
|
||||||
return "";
|
return "";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetCustomerUserId(string customerUserId)
|
public static void SetCustomerUserId(string customerUserId)
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
Log("[SetCustomerUserId] customerUserId: {0}", customerUserId);
|
Log("[SetCustomerUserId] customerUserId: {0}", customerUserId);
|
||||||
if (customerUserId.Contains("test_device:"))
|
if (customerUserId.Contains("test_device:"))
|
||||||
{
|
{
|
||||||
string testDeviceId = customerUserId.Substring(12);
|
string testDeviceId = customerUserId.Substring(12);
|
||||||
AppsFlyerTracker.GetAppsFlyerTracker().testDeviceId = testDeviceId;
|
AppsFlyerTracker.GetAppsFlyerTracker().testDeviceId = testDeviceId;
|
||||||
}
|
}
|
||||||
AppsFlyerTracker.GetAppsFlyerTracker().customerUserId = customerUserId;
|
AppsFlyerTracker.GetAppsFlyerTracker().customerUserId = customerUserId;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Start()
|
public static void Start()
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
Log("[Start]");
|
Log("[Start]");
|
||||||
AppsFlyerTracker.GetAppsFlyerTracker().TrackAppLaunchAsync(Callback);
|
AppsFlyerTracker.GetAppsFlyerTracker().TrackAppLaunchAsync(Callback);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
public static void Callback(AppsFlyerLib.ServerStatusCode code)
|
public static void Callback(AppsFlyerLib.ServerStatusCode code)
|
||||||
{
|
{
|
||||||
Log("[Callback]: {0}", code.ToString());
|
Log("[Callback]: {0}", code.ToString());
|
||||||
|
|
||||||
AppsFlyerRequestEventArgs eventArgs = new AppsFlyerRequestEventArgs((int)code, code.ToString());
|
AppsFlyerRequestEventArgs eventArgs = new AppsFlyerRequestEventArgs((int)code, code.ToString());
|
||||||
if (_gameObject != null) {
|
if (_gameObject != null) {
|
||||||
var method = _gameObject.GetType().GetMethod("AppsFlyerOnRequestResponse");
|
var method = _gameObject.GetType().GetMethod("AppsFlyerOnRequestResponse");
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
method.Invoke(_gameObject, new object[] { AppsFlyerTracker.GetAppsFlyerTracker(), eventArgs });
|
method.Invoke(_gameObject, new object[] { AppsFlyerTracker.GetAppsFlyerTracker(), eventArgs });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static void LogEvent(string eventName, Dictionary<string, string> eventValues)
|
public static void LogEvent(string eventName, Dictionary<string, string> eventValues)
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
if (eventValues == null)
|
if (eventValues == null)
|
||||||
{
|
{
|
||||||
eventValues = new Dictionary<string, string>();
|
eventValues = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
IDictionary<string, object> result = new Dictionary<string, object>();
|
IDictionary<string, object> result = new Dictionary<string, object>();
|
||||||
foreach (KeyValuePair<string, string> kvp in eventValues)
|
foreach (KeyValuePair<string, string> kvp in eventValues)
|
||||||
{
|
{
|
||||||
result.Add(kvp.Key.ToString(), kvp.Value);
|
result.Add(kvp.Key.ToString(), kvp.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log("[LogEvent]: eventName: {0} result: {1}", eventName, result.ToString());
|
Log("[LogEvent]: eventName: {0} result: {1}", eventName, result.ToString());
|
||||||
|
|
||||||
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
|
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
|
||||||
tracker.TrackEvent(eventName, result);
|
tracker.TrackEvent(eventName, result);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void GetConversionData(string _reserved)
|
public static void GetConversionData(string _reserved)
|
||||||
{
|
{
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
|
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
|
||||||
string conversionData = await tracker.GetConversionDataAsync();
|
string conversionData = await tracker.GetConversionDataAsync();
|
||||||
|
|
||||||
IAppsFlyerConversionData conversionDataHandler = _gameObject as IAppsFlyerConversionData;
|
IAppsFlyerConversionData conversionDataHandler = _gameObject as IAppsFlyerConversionData;
|
||||||
|
|
||||||
if (conversionDataHandler != null)
|
if (conversionDataHandler != null)
|
||||||
{
|
{
|
||||||
Log("[GetConversionData] Will call `onConversionDataSuccess` with: {0}", conversionData);
|
Log("[GetConversionData] Will call `onConversionDataSuccess` with: {0}", conversionData);
|
||||||
conversionDataHandler.onConversionDataSuccess(conversionData);
|
conversionDataHandler.onConversionDataSuccess(conversionData);
|
||||||
} else {
|
} else {
|
||||||
Log("[GetConversionData] Object with `IAppsFlyerConversionData` interface not found! Check `InitSDK` implementation");
|
Log("[GetConversionData] Object with `IAppsFlyerConversionData` interface not found! Check `InitSDK` implementation");
|
||||||
}
|
}
|
||||||
// _gameObject.GetType().GetMethod("onConversionDataSuccess").Invoke(_gameObject, new[] { conversionData });
|
// _gameObject.GetType().GetMethod("onConversionDataSuccess").Invoke(_gameObject, new[] { conversionData });
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Log(string format, params string[] args)
|
private static void Log(string format, params string[] args)
|
||||||
{
|
{
|
||||||
#if AFSDK_WIN_DEBUG
|
#if AFSDK_WIN_DEBUG
|
||||||
#if ENABLE_WINMD_SUPPORT
|
#if ENABLE_WINMD_SUPPORT
|
||||||
Debug.Log("AF_UNITY_WSA_10_0" + String.Format(format, args));
|
Debug.Log("AF_UNITY_WSA_10_0" + String.Format(format, args));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+20
-20
@@ -1,20 +1,20 @@
|
|||||||
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
FirebaseAnalytics iOS and Android Dependencies.
|
FirebaseAnalytics iOS and Android Dependencies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<iosPods>
|
<iosPods>
|
||||||
<iosPod name="Firebase/Analytics" version="11.10.0" minTargetSdk="13.0">
|
<iosPod name="Firebase/Analytics" version="11.10.0" minTargetSdk="13.0">
|
||||||
</iosPod>
|
</iosPod>
|
||||||
</iosPods>
|
</iosPods>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-analytics-unity:12.8.0">
|
<androidPackage spec="com.google.firebase:firebase-analytics-unity:12.8.0">
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>Assets/Firebase/m2repository</repository>
|
<repository>Assets/Firebase/m2repository</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+24
-24
@@ -1,24 +1,24 @@
|
|||||||
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
FirebaseApp iOS and Android Dependencies.
|
FirebaseApp iOS and Android Dependencies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<iosPods>
|
<iosPods>
|
||||||
<iosPod name="Firebase/Core" version="11.10.0" minTargetSdk="13.0">
|
<iosPod name="Firebase/Core" version="11.10.0" minTargetSdk="13.0">
|
||||||
</iosPod>
|
</iosPod>
|
||||||
</iosPods>
|
</iosPods>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="com.google.firebase:firebase-common:21.0.0">
|
<androidPackage spec="com.google.firebase:firebase-common:21.0.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.android.gms:play-services-base:18.6.0">
|
<androidPackage spec="com.google.android.gms:play-services-base:18.6.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-app-unity:12.8.0">
|
<androidPackage spec="com.google.firebase:firebase-app-unity:12.8.0">
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>Assets/Firebase/m2repository</repository>
|
<repository>Assets/Firebase/m2repository</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+22
-22
@@ -1,22 +1,22 @@
|
|||||||
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
FirebaseCrashlytics iOS and Android Dependencies.
|
FirebaseCrashlytics iOS and Android Dependencies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<iosPods>
|
<iosPods>
|
||||||
<iosPod name="Firebase/Crashlytics" version="11.10.0" minTargetSdk="13.0">
|
<iosPod name="Firebase/Crashlytics" version="11.10.0" minTargetSdk="13.0">
|
||||||
</iosPod>
|
</iosPod>
|
||||||
</iosPods>
|
</iosPods>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="com.google.firebase:firebase-crashlytics-ndk:19.4.2">
|
<androidPackage spec="com.google.firebase:firebase-crashlytics-ndk:19.4.2">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-crashlytics-unity:12.8.0">
|
<androidPackage spec="com.google.firebase:firebase-crashlytics-unity:12.8.0">
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>Assets/Firebase/m2repository</repository>
|
<repository>Assets/Firebase/m2repository</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+26
-26
@@ -1,26 +1,26 @@
|
|||||||
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
<!-- Copyright (C) 2019 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
FirebaseMessaging iOS and Android Dependencies.
|
FirebaseMessaging iOS and Android Dependencies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<iosPods>
|
<iosPods>
|
||||||
<iosPod name="Firebase/Messaging" version="11.10.0" minTargetSdk="13.0">
|
<iosPod name="Firebase/Messaging" version="11.10.0" minTargetSdk="13.0">
|
||||||
</iosPod>
|
</iosPod>
|
||||||
</iosPods>
|
</iosPods>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="com.google.firebase:firebase-messaging:24.1.1">
|
<androidPackage spec="com.google.firebase:firebase-messaging:24.1.1">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
<androidPackage spec="com.google.firebase:firebase-analytics:22.4.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-iid:21.1.0">
|
<androidPackage spec="com.google.firebase:firebase-iid:21.1.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.flatbuffers:flatbuffers-java:1.12.0">
|
<androidPackage spec="com.google.flatbuffers:flatbuffers-java:1.12.0">
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
<androidPackage spec="com.google.firebase:firebase-messaging-unity:12.8.0">
|
<androidPackage spec="com.google.firebase:firebase-messaging-unity:12.8.0">
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>Assets/Firebase/m2repository</repository>
|
<repository>Assets/Firebase/m2repository</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+9
-9
@@ -1,9 +1,9 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<groupId>com.google.firebase</groupId>
|
<groupId>com.google.firebase</groupId>
|
||||||
<artifactId>firebase-analytics-unity</artifactId>
|
<artifactId>firebase-analytics-unity</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<release>12.8.0</release>
|
<release>12.8.0</release>
|
||||||
<versions><version>12.8.0</version></versions>
|
<versions><version>12.8.0</version></versions>
|
||||||
<lastUpdated/>
|
<lastUpdated/>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+9
-9
@@ -1,9 +1,9 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<groupId>com.google.firebase</groupId>
|
<groupId>com.google.firebase</groupId>
|
||||||
<artifactId>firebase-app-unity</artifactId>
|
<artifactId>firebase-app-unity</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<release>12.8.0</release>
|
<release>12.8.0</release>
|
||||||
<versions><version>12.8.0</version></versions>
|
<versions><version>12.8.0</version></versions>
|
||||||
<lastUpdated/>
|
<lastUpdated/>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+9
-9
@@ -1,9 +1,9 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<groupId>com.google.firebase</groupId>
|
<groupId>com.google.firebase</groupId>
|
||||||
<artifactId>firebase-crashlytics-unity</artifactId>
|
<artifactId>firebase-crashlytics-unity</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<release>12.8.0</release>
|
<release>12.8.0</release>
|
||||||
<versions><version>12.8.0</version></versions>
|
<versions><version>12.8.0</version></versions>
|
||||||
<lastUpdated/>
|
<lastUpdated/>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+9
-9
@@ -1,9 +1,9 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<groupId>com.google.firebase</groupId>
|
<groupId>com.google.firebase</groupId>
|
||||||
<artifactId>firebase-messaging-unity</artifactId>
|
<artifactId>firebase-messaging-unity</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<release>12.8.0</release>
|
<release>12.8.0</release>
|
||||||
<versions><version>12.8.0</version></versions>
|
<versions><version>12.8.0</version></versions>
|
||||||
<lastUpdated/>
|
<lastUpdated/>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+231
-232
@@ -1,232 +1,231 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using MYp0ZVTT2QSDK;
|
using MYp0ZVTT2QSDK;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
public class MYp0ZVTT2QSDKDemo : MonoBehaviour
|
public class MYp0ZVTT2QSDKDemo : MonoBehaviour
|
||||||
{
|
{
|
||||||
public void ShowReward()
|
public void ShowReward()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.ShowRewardVideo("TAG", b =>
|
MYp0ZVTT2QSDKHelper.Instance.ShowRewardVideo("TAG", b =>
|
||||||
{
|
{
|
||||||
Debug.LogError($"reward result = {b}");
|
Debug.LogError($"reward result = {b}");
|
||||||
},(() =>
|
},(() =>
|
||||||
{
|
{
|
||||||
Debug.LogError($"reward close!!!");
|
Debug.LogError($"reward close!!!");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowInter()
|
public void ShowInter()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.ShowInter("TAG", () =>
|
MYp0ZVTT2QSDKHelper.Instance.ShowInter("TAG", () =>
|
||||||
{
|
{
|
||||||
Debug.LogError("inter hide");
|
Debug.LogError("inter hide");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowAdmobInter()
|
public void ShowAdmobInter()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.ShowAdmobInter("TAG", () =>
|
MYp0ZVTT2QSDKHelper.Instance.ShowAdmobInter("TAG", () =>
|
||||||
{
|
{
|
||||||
Debug.LogError("inter hide");
|
Debug.LogError("inter hide");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSplash()
|
public void ShowSplash()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.ShowSplash();
|
MYp0ZVTT2QSDKHelper.Instance.ShowSplash();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckReward(Image btnImg)
|
public void CheckReward(Image btnImg)
|
||||||
{
|
{
|
||||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsVideoReady();
|
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsVideoReady();
|
||||||
btnImg.color = isReady ? Color.green : Color.white;
|
btnImg.color = isReady ? Color.green : Color.white;
|
||||||
Debug.Log($"Reward : {isReady}");
|
Debug.Log($"Reward : {isReady}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckInter(Image btnImg)
|
public void CheckInter(Image btnImg)
|
||||||
{
|
{
|
||||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsInterReady();
|
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsInterReady();
|
||||||
btnImg.color = isReady ? Color.green : Color.white;
|
btnImg.color = isReady ? Color.green : Color.white;
|
||||||
Debug.Log($"Inter : {isReady}");
|
Debug.Log($"Inter : {isReady}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckSplash(Image btnImg)
|
public void CheckSplash(Image btnImg)
|
||||||
{
|
{
|
||||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsSplashReady();
|
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsSplashReady();
|
||||||
btnImg.color = isReady ? Color.green : Color.white;
|
btnImg.color = isReady ? Color.green : Color.white;
|
||||||
Debug.Log($"Splash : {isReady}");
|
Debug.Log($"Splash : {isReady}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Track()
|
public void Track()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.Track("test", new Dictionary<string, string>()
|
MYp0ZVTT2QSDKHelper.Instance.Track("test", new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"evt1", "1"},
|
{"evt1", "1"},
|
||||||
{"evt2", "2"},
|
{"evt2", "2"},
|
||||||
{"evt3", "3"},
|
{"evt3", "3"},
|
||||||
{"evt4", "4"},
|
{"evt4", "4"},
|
||||||
{"evt5", "5"},
|
{"evt5", "5"},
|
||||||
{"evt6", "6"},
|
{"evt6", "6"},
|
||||||
{"evt7", "7"},
|
{"evt7", "7"},
|
||||||
{"evt8", "8"},
|
{"evt8", "8"},
|
||||||
{"evt9", "9"},
|
{"evt9", "9"},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetCountryCode()
|
public void GetCountryCode()
|
||||||
{
|
{
|
||||||
|
|
||||||
var code = MYp0ZVTT2QSDKHelper.Instance.GetCountryCode();
|
var code = MYp0ZVTT2QSDKHelper.Instance.GetCountryCode();
|
||||||
Debug.Log($"country : {code}");
|
Debug.Log($"country : {code}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowH5()
|
public void ShowH5()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5((() =>
|
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5((() =>
|
||||||
{
|
{
|
||||||
Debug.Log("H5 close");
|
Debug.Log("H5 close");
|
||||||
}), () =>
|
}), () =>
|
||||||
{
|
{
|
||||||
Debug.Log($"H5 show failed!");
|
Debug.Log($"H5 show failed!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowH5(RectTransform rectTransform)
|
public void ShowH5(RectTransform rectTransform)
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5(rectTransform);
|
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5(rectTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideH5()
|
public void HideH5()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.H5.HideH5();
|
MYp0ZVTT2QSDKHelper.Instance.H5.HideH5();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckShowH5(Image btnImg)
|
public void CheckShowH5(Image btnImg)
|
||||||
{
|
{
|
||||||
var show = MYp0ZVTT2QSDKHelper.Instance.H5.IsShowH5();
|
var show = MYp0ZVTT2QSDKHelper.Instance.H5.IsShowH5();
|
||||||
btnImg.color = show ? Color.green : Color.red;
|
btnImg.color = show ? Color.green : Color.red;
|
||||||
Debug.Log($"CheckShowH5 : {show}");
|
Debug.Log($"CheckShowH5 : {show}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _level = 1;
|
private int _level = 1;
|
||||||
public void TrackLevel()
|
public void TrackLevel()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.TrackLevelUp(_level);
|
MYp0ZVTT2QSDKHelper.Instance.TrackLevelUp(_level);
|
||||||
if (Random.Range(0, 100) < 50)
|
if (Random.Range(0, 100) < 50)
|
||||||
{
|
{
|
||||||
_level++;
|
_level++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string withDrawSceneId = "";
|
private string withDrawSceneId = "";
|
||||||
public void GetWithDrawConfigs()
|
public void GetWithDrawConfigs()
|
||||||
{
|
{
|
||||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawConfigs(((b, s) =>
|
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawConfigs(((b, s) =>
|
||||||
{
|
{
|
||||||
Debug.Log($"GetWithDrawConfigs result : {b}, data : {s}");
|
Debug.Log($"GetWithDrawConfigs result : {b}, data : {s}");
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawConfig>>(s);
|
var cfgs = JsonConvert.DeserializeObject<List<WithDrawConfig>>(s);
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
foreach (WithDrawConfig config in cfgs)
|
foreach (WithDrawConfig config in cfgs)
|
||||||
{
|
{
|
||||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
withDrawSceneId = config.SecneId;
|
withDrawSceneId = config.SecneId;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int payIndex = 0;
|
private int payIndex = 0;
|
||||||
public void CreateWithDrawOrder()
|
public void CreateWithDrawOrder()
|
||||||
{
|
{
|
||||||
string taxNo = "99999999999";
|
string taxNo = "";
|
||||||
string payAccount = "tom@gmail.com";
|
string payAccount = "tom@gmail.com";
|
||||||
string accountType = "E";
|
string accountType = "E";
|
||||||
string payeeName = "testName";
|
PaymentTypeCode payCode = PaymentTypeCode.GOPAY;
|
||||||
PaymentTypeCode payCode = PaymentTypeCode.PAYPAL;
|
//GOPAY DANA 收款账号需要为电话号码
|
||||||
////GOPAY DANA 收款账号需要为电话号码
|
if (payIndex == 1 || payIndex == 0)
|
||||||
//if (payIndex == 1 || payIndex == 0)
|
{
|
||||||
//{
|
payCode = payIndex == 1 ? PaymentTypeCode.DANA : payCode;
|
||||||
// payCode = payIndex == 1 ? PaymentTypeCode.DANA : payCode;
|
payAccount = "0881234567890";
|
||||||
// payAccount = "0881234567890";
|
accountType = "P";
|
||||||
// accountType = "P";
|
}
|
||||||
//}
|
if (payIndex == 2)
|
||||||
//if (payIndex == 2)
|
{
|
||||||
//{
|
// PIX 需要填写税号
|
||||||
// // PIX 需要填写税号
|
payCode = PaymentTypeCode.PIX;
|
||||||
// payCode = PaymentTypeCode.PIX;
|
taxNo = "99999999999";
|
||||||
// taxNo = "99999999999";
|
}
|
||||||
//}
|
if (payIndex == 3) payCode = PaymentTypeCode.MERCADOPAGO;
|
||||||
//if (payIndex == 3) payCode = PaymentTypeCode.MERCADOPAGO;
|
MYp0ZVTT2QSDKHelper.Instance.CreateWithDrawOrder(withDrawSceneId, payCode, payAccount, accountType, "testName", taxNo, b =>
|
||||||
MYp0ZVTT2QSDKHelper.Instance.CreateWithDrawOrder(withDrawSceneId, payCode, payAccount, accountType, payeeName, taxNo, b =>
|
{
|
||||||
{
|
Debug.Log($"CreateWithDrawOrder result : {b}");
|
||||||
Debug.Log($"CreateWithDrawOrder result : {b}");
|
});
|
||||||
});
|
|
||||||
|
payIndex++;
|
||||||
payIndex++;
|
payIndex = payIndex > 3 ? 0 : payIndex;
|
||||||
payIndex = payIndex > 3 ? 0 : payIndex;
|
}
|
||||||
}
|
|
||||||
|
public void GetWithDrawOrders()
|
||||||
public void GetWithDrawOrders()
|
{
|
||||||
{
|
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawOrders(((b, s) =>
|
||||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawOrders(((b, s) =>
|
{
|
||||||
{
|
Debug.Log($"GetWithDrawOrders result : {b}, data : {s}");
|
||||||
Debug.Log($"GetWithDrawOrders result : {b}, data : {s}");
|
if (b)
|
||||||
if (b)
|
{
|
||||||
{
|
var cfgs = JsonConvert.DeserializeObject<List<WithDrawOrder>>(s);
|
||||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawOrder>>(s);
|
int idx = 0;
|
||||||
int idx = 0;
|
foreach (WithDrawOrder config in cfgs)
|
||||||
foreach (WithDrawOrder config in cfgs)
|
{
|
||||||
{
|
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
idx++;
|
||||||
idx++;
|
}
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
}));
|
}
|
||||||
}
|
|
||||||
|
// Start is called before the first frame update
|
||||||
// Start is called before the first frame update
|
void Start()
|
||||||
void Start()
|
{
|
||||||
{
|
Init();
|
||||||
Init();
|
|
||||||
|
Invoke("ShowSplash", 5);
|
||||||
Invoke("ShowSplash", 5);
|
}
|
||||||
}
|
|
||||||
|
// Update is called once per frame
|
||||||
// Update is called once per frame
|
void Update()
|
||||||
void Update()
|
{
|
||||||
{
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
private void Init()
|
||||||
private void Init()
|
{
|
||||||
{
|
MYp0ZVTT2QSDKHelper.Instance.RegistIosParam((i =>
|
||||||
MYp0ZVTT2QSDKHelper.Instance.RegistIosParam((i =>
|
{
|
||||||
{
|
Debug.Log($"ios ab param : {i}");
|
||||||
Debug.Log($"ios ab param : {i}");
|
}));
|
||||||
}));
|
|
||||||
|
void GameConfig(bool result, string config)
|
||||||
void GameConfig(bool result, string config)
|
{
|
||||||
{
|
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
}
|
||||||
}
|
|
||||||
|
MYp0ZVTT2QSDKHelper.Instance.Init(null, "app_config", GameConfig);
|
||||||
MYp0ZVTT2QSDKHelper.Instance.Init(null, "app_config", GameConfig);
|
}
|
||||||
}
|
|
||||||
|
public static string GetSdkVersion()
|
||||||
public static string GetSdkVersion()
|
{
|
||||||
{
|
return MYp0ZVTT2QSDKHelper.SdkVersion;
|
||||||
return MYp0ZVTT2QSDKHelper.SdkVersion;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Regular → Executable
+11
-11
@@ -1,11 +1,11 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 959ec24a7131c9d488e5007fa82612be
|
guid: 959ec24a7131c9d488e5007fa82612be
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|||||||
Regular → Executable
+653
-653
File diff suppressed because it is too large
Load Diff
Regular → Executable
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 64a340d6f61782b4c8c883b62e1d5534
|
guid: 388c0b17792cece47ba42e51b68fbd6b
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
Regular → Executable
+16
-16
@@ -1,17 +1,17 @@
|
|||||||
package com.tool.countrycode;
|
package com.tool.countrycode;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
public class AcquireCountryCode {
|
public class AcquireCountryCode {
|
||||||
// 获取国家码
|
// 获取国家码
|
||||||
public static String getCountryCode()
|
public static String getCountryCode()
|
||||||
{
|
{
|
||||||
Locale locale = Locale.getDefault();
|
Locale locale = Locale.getDefault();
|
||||||
return locale.getCountry();
|
return locale.getCountry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCountryCode3() {
|
public static String getCountryCode3() {
|
||||||
Locale currentLocale = Locale.getDefault();
|
Locale currentLocale = Locale.getDefault();
|
||||||
return currentLocale.getISO3Country();
|
return currentLocale.getISO3Country();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Regular → Executable
Regular → Executable
Regular → Executable
+33
-33
@@ -1,33 +1,33 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6e3da5c7fe21c1347a563e64e8f305d4
|
guid: 6e3da5c7fe21c1347a563e64e8f305d4
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
iconMap: {}
|
iconMap: {}
|
||||||
executionOrder: {}
|
executionOrder: {}
|
||||||
defineConstraints: []
|
defineConstraints: []
|
||||||
isPreloaded: 0
|
isPreloaded: 0
|
||||||
isOverridable: 0
|
isOverridable: 0
|
||||||
isExplicitlyReferenced: 0
|
isExplicitlyReferenced: 0
|
||||||
validateReferences: 1
|
validateReferences: 1
|
||||||
platformData:
|
platformData:
|
||||||
- first:
|
- first:
|
||||||
Any:
|
Any:
|
||||||
second:
|
second:
|
||||||
enabled: 1
|
enabled: 1
|
||||||
settings: {}
|
settings: {}
|
||||||
- first:
|
- first:
|
||||||
Editor: Editor
|
Editor: Editor
|
||||||
second:
|
second:
|
||||||
enabled: 0
|
enabled: 0
|
||||||
settings:
|
settings:
|
||||||
DefaultValueInitialized: true
|
DefaultValueInitialized: true
|
||||||
- first:
|
- first:
|
||||||
Windows Store Apps: WindowsStoreApps
|
Windows Store Apps: WindowsStoreApps
|
||||||
second:
|
second:
|
||||||
enabled: 0
|
enabled: 0
|
||||||
settings:
|
settings:
|
||||||
CPU: AnyCPU
|
CPU: AnyCPU
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|||||||
Regular → Executable
BIN
Binary file not shown.
Regular → Executable
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 380fbd6cbea0c354494400b091a059f7
|
guid: fe19acc38fc5b2c44bd76633a63d0d6b
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
Regular → Executable
+12
-12
@@ -1,12 +1,12 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility("default")))
|
||||||
const char* _GetDeviceCountryCode() {
|
const char* _GetDeviceCountryCode() {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSLocale *currentLocale = [NSLocale currentLocale];
|
NSLocale *currentLocale = [NSLocale currentLocale];
|
||||||
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
|
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
|
||||||
return strdup([countryCode UTF8String]); // 使用strdup确保内存安全
|
return strdup([countryCode UTF8String]); // 使用strdup确保内存安全
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+13
-13
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "SDKConfig",
|
"name": "SDKConfig",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [],
|
"references": [],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
"defineConstraints": [],
|
"defineConstraints": [],
|
||||||
"versionDefines": [],
|
"versionDefines": [],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
}
|
}
|
||||||
Regular → Executable
+7
-7
@@ -1,7 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 8b6da46957b38914aa097a61bd86a16d
|
guid: 8b6da46957b38914aa097a61bd86a16d
|
||||||
AssemblyDefinitionImporter:
|
AssemblyDefinitionImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|||||||
Regular → Executable
+234
-234
@@ -1,234 +1,234 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MYp0ZVTT2QSDK
|
namespace MYp0ZVTT2QSDK
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class SDKConfig : ScriptableObject
|
public class SDKConfig : ScriptableObject
|
||||||
{
|
{
|
||||||
|
|
||||||
public string appsFlyerDevKey;
|
public string appsFlyerDevKey;
|
||||||
|
|
||||||
public string appsFlyerIosAppleAppId;
|
public string appsFlyerIosAppleAppId;
|
||||||
|
|
||||||
public string appKey;
|
public string appKey;
|
||||||
|
|
||||||
public string appSecret;
|
public string appSecret;
|
||||||
|
|
||||||
public string logReportUrl;
|
public string logReportUrl;
|
||||||
|
|
||||||
public string maxAppKey;
|
public string maxAppKey;
|
||||||
|
|
||||||
public string splashUnitId;
|
public string splashUnitId;
|
||||||
|
|
||||||
public string bannerUnitId;
|
public string bannerUnitId;
|
||||||
|
|
||||||
public string interUnitId;
|
public string interUnitId;
|
||||||
|
|
||||||
public string videoUnitId;
|
public string videoUnitId;
|
||||||
|
|
||||||
public string kwaiAppId;
|
public string kwaiAppId;
|
||||||
|
|
||||||
public List<string> kwaiVideoUnitId = new();
|
public List<string> kwaiVideoUnitId = new();
|
||||||
|
|
||||||
public List<string> kwaiInterUnitId = new();
|
public List<string> kwaiInterUnitId = new();
|
||||||
|
|
||||||
public string bigoAppId;
|
public string bigoAppId;
|
||||||
|
|
||||||
public List<string> bigoVideoUnitId = new();
|
public List<string> bigoVideoUnitId = new();
|
||||||
|
|
||||||
public List<string> bigoInterUnitId = new();
|
public List<string> bigoInterUnitId = new();
|
||||||
|
|
||||||
public string bigoSplashUnitId;
|
public string bigoSplashUnitId;
|
||||||
|
|
||||||
public string toponAppId;
|
public string toponAppId;
|
||||||
|
|
||||||
public string toponAppkey;
|
public string toponAppkey;
|
||||||
|
|
||||||
public string toponVideoUnitId;
|
public string toponVideoUnitId;
|
||||||
|
|
||||||
public string toponInterUnitId;
|
public string toponInterUnitId;
|
||||||
|
|
||||||
public string admobAppId;
|
public string admobAppId;
|
||||||
|
|
||||||
public string admobVideoUnitId;
|
public string admobVideoUnitId;
|
||||||
|
|
||||||
public string admobInterUnitId;
|
public string admobInterUnitId;
|
||||||
|
|
||||||
public string admobSplashUnitId;
|
public string admobSplashUnitId;
|
||||||
|
|
||||||
public bool isDebug = false;
|
public bool isDebug = false;
|
||||||
|
|
||||||
public bool isPrintLog = false;
|
public bool isPrintLog = false;
|
||||||
|
|
||||||
public bool isUseAdmobSplash = false;
|
public bool isUseAdmobSplash = false;
|
||||||
|
|
||||||
private static SDKConfig _instance;
|
private static SDKConfig _instance;
|
||||||
|
|
||||||
public static SDKConfig Instance
|
public static SDKConfig Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_instance != null) return _instance;
|
if (_instance != null) return _instance;
|
||||||
_instance = AssetUtils.GetScriptableObject<SDKConfig>(typeof(SDKConfig).Name, "Assets/Resources", false, false);
|
_instance = AssetUtils.GetScriptableObject<SDKConfig>(typeof(SDKConfig).Name, "Assets/Resources", false, false);
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_instance = value;
|
_instance = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AppsFlyerDevKey
|
public static string AppsFlyerDevKey
|
||||||
{
|
{
|
||||||
get { return Instance.appsFlyerDevKey; }
|
get { return Instance.appsFlyerDevKey; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AppsFlyerIosAppleAppId
|
public static string AppsFlyerIosAppleAppId
|
||||||
{
|
{
|
||||||
get { return Instance.appsFlyerIosAppleAppId; }
|
get { return Instance.appsFlyerIosAppleAppId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AppKey
|
public static string AppKey
|
||||||
{
|
{
|
||||||
get { return Instance.appKey; }
|
get { return Instance.appKey; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AppSecret
|
public static string AppSecret
|
||||||
{
|
{
|
||||||
get { return Instance.appSecret; }
|
get { return Instance.appSecret; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string LogReportUrl
|
public static string LogReportUrl
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!Instance.logReportUrl.StartsWith("http"))
|
if (!Instance.logReportUrl.StartsWith("http"))
|
||||||
{
|
{
|
||||||
return "https://" + Instance.logReportUrl.Replace(" ", ""); ;
|
return "https://" + Instance.logReportUrl.Replace(" ", ""); ;
|
||||||
}
|
}
|
||||||
return Instance.logReportUrl.Replace(" ", ""); ;
|
return Instance.logReportUrl.Replace(" ", ""); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MaxAppKey
|
public static string MaxAppKey
|
||||||
{
|
{
|
||||||
get { return Instance.maxAppKey; }
|
get { return Instance.maxAppKey; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SplashUnitID
|
public static string SplashUnitID
|
||||||
{
|
{
|
||||||
get { return Instance.splashUnitId; }
|
get { return Instance.splashUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BannerUnitId
|
public static string BannerUnitId
|
||||||
{
|
{
|
||||||
get { return Instance.bannerUnitId; }
|
get { return Instance.bannerUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string InterUnitId
|
public static string InterUnitId
|
||||||
{
|
{
|
||||||
get { return Instance.interUnitId; }
|
get { return Instance.interUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string VideoUnitId
|
public static string VideoUnitId
|
||||||
{
|
{
|
||||||
get { return Instance.videoUnitId; }
|
get { return Instance.videoUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string KwaiAppId
|
public static string KwaiAppId
|
||||||
{
|
{
|
||||||
get => Instance.kwaiAppId;
|
get => Instance.kwaiAppId;
|
||||||
set => Instance.kwaiAppId = value;
|
set => Instance.kwaiAppId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> KwaiVideoUnitId
|
public static List<string> KwaiVideoUnitId
|
||||||
{
|
{
|
||||||
get => Instance.kwaiVideoUnitId;
|
get => Instance.kwaiVideoUnitId;
|
||||||
set => Instance.kwaiVideoUnitId = value;
|
set => Instance.kwaiVideoUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> KwaiInterUnitId
|
public static List<string> KwaiInterUnitId
|
||||||
{
|
{
|
||||||
get => Instance.kwaiInterUnitId;
|
get => Instance.kwaiInterUnitId;
|
||||||
set => Instance.kwaiInterUnitId = value;
|
set => Instance.kwaiInterUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BigoAppId
|
public static string BigoAppId
|
||||||
{
|
{
|
||||||
get => Instance.bigoAppId;
|
get => Instance.bigoAppId;
|
||||||
set => Instance.bigoAppId = value;
|
set => Instance.bigoAppId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> BigoVideoUnitId
|
public static List<string> BigoVideoUnitId
|
||||||
{
|
{
|
||||||
get => Instance.bigoVideoUnitId;
|
get => Instance.bigoVideoUnitId;
|
||||||
set => Instance.bigoVideoUnitId = value;
|
set => Instance.bigoVideoUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> BigoInterUnitId
|
public static List<string> BigoInterUnitId
|
||||||
{
|
{
|
||||||
get => Instance.bigoInterUnitId;
|
get => Instance.bigoInterUnitId;
|
||||||
set => Instance.bigoInterUnitId = value;
|
set => Instance.bigoInterUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BigoSplashUnitId
|
public static string BigoSplashUnitId
|
||||||
{
|
{
|
||||||
get => Instance.bigoSplashUnitId;
|
get => Instance.bigoSplashUnitId;
|
||||||
set => Instance.bigoSplashUnitId = value;
|
set => Instance.bigoSplashUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToponAppId
|
public static string ToponAppId
|
||||||
{
|
{
|
||||||
get { return Instance.toponAppId; }
|
get { return Instance.toponAppId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToponAppkey
|
public static string ToponAppkey
|
||||||
{
|
{
|
||||||
get { return Instance.toponAppkey; }
|
get { return Instance.toponAppkey; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToponVideoUnitId
|
public static string ToponVideoUnitId
|
||||||
{
|
{
|
||||||
get { return Instance.toponVideoUnitId; }
|
get { return Instance.toponVideoUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToponInterUnitId
|
public static string ToponInterUnitId
|
||||||
{
|
{
|
||||||
get { return Instance.toponInterUnitId; }
|
get { return Instance.toponInterUnitId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AdmobAppId
|
public static string AdmobAppId
|
||||||
{
|
{
|
||||||
get => Instance.admobAppId;
|
get => Instance.admobAppId;
|
||||||
set => Instance.admobAppId = value;
|
set => Instance.admobAppId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AdmobVideoUnitId
|
public static string AdmobVideoUnitId
|
||||||
{
|
{
|
||||||
get => Instance.admobVideoUnitId;
|
get => Instance.admobVideoUnitId;
|
||||||
set => Instance.admobVideoUnitId = value;
|
set => Instance.admobVideoUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AdmobSplashUnitId
|
public static string AdmobSplashUnitId
|
||||||
{
|
{
|
||||||
get => Instance.admobSplashUnitId;
|
get => Instance.admobSplashUnitId;
|
||||||
set => Instance.admobSplashUnitId = value;
|
set => Instance.admobSplashUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AdmobInterUnitId
|
public static string AdmobInterUnitId
|
||||||
{
|
{
|
||||||
get => Instance.admobInterUnitId;
|
get => Instance.admobInterUnitId;
|
||||||
set => Instance.admobInterUnitId = value;
|
set => Instance.admobInterUnitId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDebug => Instance.isDebug;
|
public static bool IsDebug => Instance.isDebug;
|
||||||
|
|
||||||
public static bool IsPrintLog => Instance.isPrintLog;
|
public static bool IsPrintLog => Instance.isPrintLog;
|
||||||
|
|
||||||
public static bool IsUseAdmobSplash => Instance.isUseAdmobSplash;
|
public static bool IsUseAdmobSplash => Instance.isUseAdmobSplash;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
+152
-152
@@ -1,152 +1,152 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace MYp0ZVTT2QSDK
|
namespace MYp0ZVTT2QSDK
|
||||||
{
|
{
|
||||||
public static class AssetUtils
|
public static class AssetUtils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a reference to a scriptable object of type T with the given fileName at the relative resourcesPath.
|
/// Returns a reference to a scriptable object of type T with the given fileName at the relative resourcesPath.
|
||||||
/// <para/> If the asset is not found, one will get created automatically (in the Editor only)
|
/// <para/> If the asset is not found, one will get created automatically (in the Editor only)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <param name="resourcesPath"></param>
|
/// <param name="resourcesPath"></param>
|
||||||
/// <param name="saveAssetDatabase"></param>
|
/// <param name="saveAssetDatabase"></param>
|
||||||
/// <param name="refreshAssetDatabase"></param>
|
/// <param name="refreshAssetDatabase"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T GetScriptableObject<T>(string fileName,
|
public static T GetScriptableObject<T>(string fileName,
|
||||||
string resourcesPath,
|
string resourcesPath,
|
||||||
bool saveAssetDatabase,
|
bool saveAssetDatabase,
|
||||||
bool refreshAssetDatabase)
|
bool refreshAssetDatabase)
|
||||||
where T : ScriptableObject
|
where T : ScriptableObject
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||||
if (string.IsNullOrEmpty(fileName)) return null;
|
if (string.IsNullOrEmpty(fileName)) return null;
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||||
resourcesPath = CleanPath(resourcesPath);
|
resourcesPath = CleanPath(resourcesPath);
|
||||||
|
|
||||||
var obj = (T)Resources.Load(fileName, typeof(T));
|
var obj = (T)Resources.Load(fileName, typeof(T));
|
||||||
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
string simpleResourcesPath = resourcesPath.Replace(resourcesPath.Substring(0, resourcesPath.LastIndexOf("Resources", StringComparison.Ordinal)), "");
|
string simpleResourcesPath = resourcesPath.Replace(resourcesPath.Substring(0, resourcesPath.LastIndexOf("Resources", StringComparison.Ordinal)), "");
|
||||||
simpleResourcesPath = simpleResourcesPath.Replace("Resources", "").Remove(0, 1);
|
simpleResourcesPath = simpleResourcesPath.Replace("Resources", "").Remove(0, 1);
|
||||||
obj = (T)Resources.Load(Path.Combine(simpleResourcesPath, fileName), typeof(T));
|
obj = (T)Resources.Load(Path.Combine(simpleResourcesPath, fileName), typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (obj != null) return obj;
|
if (obj != null) return obj;
|
||||||
if (!Directory.Exists("Assets/Resources"))
|
if (!Directory.Exists("Assets/Resources"))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory("Assets/Resources");
|
Directory.CreateDirectory("Assets/Resources");
|
||||||
}
|
}
|
||||||
obj = CreateAsset<T>(resourcesPath, fileName, ".asset", saveAssetDatabase, refreshAssetDatabase);
|
obj = CreateAsset<T>(resourcesPath, fileName, ".asset", saveAssetDatabase, refreshAssetDatabase);
|
||||||
#endif
|
#endif
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T GetResource<T>(string resourcesPath, string fileName) where T : ScriptableObject
|
public static T GetResource<T>(string resourcesPath, string fileName) where T : ScriptableObject
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||||
if (string.IsNullOrEmpty(fileName)) return null;
|
if (string.IsNullOrEmpty(fileName)) return null;
|
||||||
resourcesPath = CleanPath(resourcesPath);
|
resourcesPath = CleanPath(resourcesPath);
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||||
|
|
||||||
return (T)Resources.Load(resourcesPath + fileName, typeof(T));
|
return (T)Resources.Load(resourcesPath + fileName, typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CleanPath(string path)
|
public static string CleanPath(string path)
|
||||||
{
|
{
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
if (!path[path.Length - 1].Equals(@"\")) path += @"\";
|
if (!path[path.Length - 1].Equals(@"\")) path += @"\";
|
||||||
path = path.Replace(@"\\", @"\");
|
path = path.Replace(@"\\", @"\");
|
||||||
path = path.Replace(@"\", "/");
|
path = path.Replace(@"\", "/");
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
public static T CreateAsset<T>(string relativePath,
|
public static T CreateAsset<T>(string relativePath,
|
||||||
string fileName,
|
string fileName,
|
||||||
string extension = ".asset",
|
string extension = ".asset",
|
||||||
bool saveAssetDatabase = true,
|
bool saveAssetDatabase = true,
|
||||||
bool refreshAssetDatabase = true)
|
bool refreshAssetDatabase = true)
|
||||||
where T : ScriptableObject
|
where T : ScriptableObject
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(relativePath)) return null;
|
if (string.IsNullOrEmpty(relativePath)) return null;
|
||||||
if (string.IsNullOrEmpty(fileName)) return null;
|
if (string.IsNullOrEmpty(fileName)) return null;
|
||||||
relativePath = CleanPath(relativePath);
|
relativePath = CleanPath(relativePath);
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||||
// relativePath = relativePath.Replace(@"\\", @"\");
|
// relativePath = relativePath.Replace(@"\\", @"\");
|
||||||
var asset = ScriptableObject.CreateInstance<T>();
|
var asset = ScriptableObject.CreateInstance<T>();
|
||||||
AssetDatabase.CreateAsset(asset, relativePath + fileName + extension);
|
AssetDatabase.CreateAsset(asset, relativePath + fileName + extension);
|
||||||
EditorUtility.SetDirty(asset);
|
EditorUtility.SetDirty(asset);
|
||||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<T> GetAssets<T>() where T : ScriptableObject
|
public static List<T> GetAssets<T>() where T : ScriptableObject
|
||||||
{
|
{
|
||||||
var list = new List<T>();
|
var list = new List<T>();
|
||||||
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
|
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
|
||||||
foreach (string guid in guids)
|
foreach (string guid in guids)
|
||||||
{
|
{
|
||||||
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
|
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
|
||||||
if (asset == null) continue;
|
if (asset == null) continue;
|
||||||
list.Add(asset);
|
list.Add(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
|
public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
|
||||||
bool refreshAssetDatabase = true, bool printDebugMessage = true)
|
bool refreshAssetDatabase = true, bool printDebugMessage = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(relativePath)) return;
|
if (string.IsNullOrEmpty(relativePath)) return;
|
||||||
if (string.IsNullOrEmpty(fileName)) return;
|
if (string.IsNullOrEmpty(fileName)) return;
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||||
relativePath = CleanPath(relativePath);
|
relativePath = CleanPath(relativePath);
|
||||||
if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset")) return;
|
if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset")) return;
|
||||||
if (printDebugMessage) Debug.Log("The " + fileName + ".asset file has been moved to trash.");
|
if (printDebugMessage) Debug.Log("The " + fileName + ".asset file has been moved to trash.");
|
||||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Texture GetTexture(string filePath, string fileName, string fileExtension = ".png")
|
public static Texture GetTexture(string filePath, string fileName, string fileExtension = ".png")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(filePath)) return null;
|
if (string.IsNullOrEmpty(filePath)) return null;
|
||||||
if (string.IsNullOrEmpty(fileName)) return null;
|
if (string.IsNullOrEmpty(fileName)) return null;
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||||
filePath = CleanPath(filePath);
|
filePath = CleanPath(filePath);
|
||||||
return AssetDatabase.LoadAssetAtPath<Texture>(filePath + fileName + fileExtension);
|
return AssetDatabase.LoadAssetAtPath<Texture>(filePath + fileName + fileExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Texture2D GetTexture2D(string filePath, string fileName, string fileExtension = ".png")
|
public static Texture2D GetTexture2D(string filePath, string fileName, string fileExtension = ".png")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(filePath)) return null;
|
if (string.IsNullOrEmpty(filePath)) return null;
|
||||||
if (string.IsNullOrEmpty(fileName)) return null;
|
if (string.IsNullOrEmpty(fileName)) return null;
|
||||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||||
filePath = CleanPath(filePath);
|
filePath = CleanPath(filePath);
|
||||||
return AssetDatabase.LoadAssetAtPath<Texture2D>(filePath + fileName + fileExtension);
|
return AssetDatabase.LoadAssetAtPath<Texture2D>(filePath + fileName + fileExtension);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+71
@@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AppsFlyerSDK
|
||||||
|
{
|
||||||
|
public enum MediationNetwork : ulong
|
||||||
|
{
|
||||||
|
GoogleAdMob = 1,
|
||||||
|
IronSource = 2,
|
||||||
|
ApplovinMax = 3,
|
||||||
|
Fyber = 4,
|
||||||
|
Appodeal = 5,
|
||||||
|
Admost = 6,
|
||||||
|
Topon = 7,
|
||||||
|
Tradplus = 8,
|
||||||
|
Yandex = 9,
|
||||||
|
ChartBoost = 10,
|
||||||
|
Unity = 11,
|
||||||
|
ToponPte = 12,
|
||||||
|
Custom = 13,
|
||||||
|
DirectMonetization = 14
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AdRevenueScheme
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* code ISO 3166-1 format
|
||||||
|
*/
|
||||||
|
public const string COUNTRY = "country";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the ad unit for the impression
|
||||||
|
*/
|
||||||
|
public const string AD_UNIT = "ad_unit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format of the ad
|
||||||
|
*/
|
||||||
|
public const string AD_TYPE = "ad_type";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the ad placement for the impression
|
||||||
|
*/
|
||||||
|
public const string PLACEMENT = "placement";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
// Data class representing ad revenue information.
|
||||||
|
//
|
||||||
|
// @property monetizationNetwork The name of the network that monetized the ad.
|
||||||
|
// @property mediationNetwork An instance of MediationNetwork representing the mediation service used.
|
||||||
|
// @property currencyIso4217Code The ISO 4217 currency code describing the currency of the revenue.
|
||||||
|
// @property eventRevenue The amount of revenue generated by the ad.
|
||||||
|
/// </summary>
|
||||||
|
public class AFAdRevenueData
|
||||||
|
{
|
||||||
|
public string monetizationNetwork { get; private set; }
|
||||||
|
public MediationNetwork mediationNetwork { get; private set; }
|
||||||
|
public string currencyIso4217Code { get; private set; }
|
||||||
|
public double eventRevenue { get; private set; }
|
||||||
|
|
||||||
|
public AFAdRevenueData(string monetization, MediationNetwork mediation, string currency, double revenue)
|
||||||
|
{
|
||||||
|
monetizationNetwork = monetization;
|
||||||
|
mediationNetwork = mediation;
|
||||||
|
currencyIso4217Code = currency;
|
||||||
|
eventRevenue = revenue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49e1906ae949e4bfea400bd1da9f7e39
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+426
@@ -0,0 +1,426 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AppsFlyerSDK
|
||||||
|
{
|
||||||
|
|
||||||
|
public interface IAppsFlyerPurchaseRevenueDataSource
|
||||||
|
{
|
||||||
|
Dictionary<string, object> PurchaseRevenueAdditionalParametersForProducts(HashSet<object> products, HashSet<object> transactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IAppsFlyerPurchaseRevenueDataSourceStoreKit2
|
||||||
|
{
|
||||||
|
Dictionary<string, object> PurchaseRevenueAdditionalParametersStoreKit2ForProducts(HashSet<object> products, HashSet<object> transactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AppsFlyerPurchaseRevenueBridge : MonoBehaviour
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void RegisterUnityPurchaseRevenueParamsCallback(Func<string, string, string> callback);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void RegisterUnityPurchaseRevenueParamsCallbackSK2(Func<string, string, string> callback);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private static IAppsFlyerPurchaseRevenueDataSource _dataSource;
|
||||||
|
private static IAppsFlyerPurchaseRevenueDataSourceStoreKit2 _dataSourceSK2;
|
||||||
|
|
||||||
|
public static void RegisterDataSource(IAppsFlyerPurchaseRevenueDataSource dataSource)
|
||||||
|
{
|
||||||
|
_dataSource = dataSource;
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
RegisterUnityPurchaseRevenueParamsCallback(GetAdditionalParameters);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
using (AndroidJavaClass jc = new AndroidJavaClass("com.appsflyer.unity.PurchaseRevenueBridge"))
|
||||||
|
{
|
||||||
|
jc.CallStatic("setUnityBridge", new UnityPurchaseRevenueBridgeProxy());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterDataSourceStoreKit2(IAppsFlyerPurchaseRevenueDataSourceStoreKit2 dataSource)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_dataSourceSK2 = dataSource;
|
||||||
|
RegisterUnityPurchaseRevenueParamsCallbackSK2(GetAdditionalParametersSK2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<string, object> GetAdditionalParametersForAndroid(HashSet<object> products, HashSet<object> transactions)
|
||||||
|
{
|
||||||
|
return _dataSource?.PurchaseRevenueAdditionalParametersForProducts(products, transactions)
|
||||||
|
?? new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(Func<string, string, string>))]
|
||||||
|
public static string GetAdditionalParameters(string productsJson, string transactionsJson)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HashSet<object> products = new HashSet<object>();
|
||||||
|
HashSet<object> transactions = new HashSet<object>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(productsJson))
|
||||||
|
{
|
||||||
|
var dict = AFMiniJSON.Json.Deserialize(productsJson) as Dictionary<string, object>;
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
if (dict.TryGetValue("products", out var productsObj) && productsObj is List<object> productList)
|
||||||
|
products = new HashSet<object>(productList);
|
||||||
|
|
||||||
|
if (dict.TryGetValue("transactions", out var transactionsObj) && transactionsObj is List<object> transactionList)
|
||||||
|
transactions = new HashSet<object>(transactionList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameters = _dataSource?.PurchaseRevenueAdditionalParametersForProducts(products, transactions)
|
||||||
|
?? new Dictionary<string, object>();
|
||||||
|
return AFMiniJSON.Json.Serialize(parameters);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[AppsFlyer] Exception in GetAdditionalParameters: {e}");
|
||||||
|
return "{}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(Func<string, string, string>))]
|
||||||
|
public static string GetAdditionalParametersSK2(string productsJson, string transactionsJson)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HashSet<object> products = new HashSet<object>();
|
||||||
|
HashSet<object> transactions = new HashSet<object>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(productsJson))
|
||||||
|
{
|
||||||
|
var dict = AFMiniJSON.Json.Deserialize(productsJson) as Dictionary<string, object>;
|
||||||
|
if (dict != null && dict.TryGetValue("products", out var productsObj) && productsObj is List<object> productList)
|
||||||
|
products = new HashSet<object>(productList);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(transactionsJson))
|
||||||
|
{
|
||||||
|
var dict = AFMiniJSON.Json.Deserialize(transactionsJson) as Dictionary<string, object>;
|
||||||
|
if (dict != null && dict.TryGetValue("transactions", out var transactionsObj) && transactionsObj is List<object> transactionList)
|
||||||
|
transactions = new HashSet<object>(transactionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameters = _dataSourceSK2?.PurchaseRevenueAdditionalParametersStoreKit2ForProducts(products, transactions)
|
||||||
|
?? new Dictionary<string, object>();
|
||||||
|
return AFMiniJSON.Json.Serialize(parameters);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[AppsFlyer] Exception in GetAdditionalParametersSK2: {e}");
|
||||||
|
return "{}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnityPurchaseRevenueBridgeProxy : AndroidJavaProxy
|
||||||
|
{
|
||||||
|
public UnityPurchaseRevenueBridgeProxy() : base("com.appsflyer.unity.PurchaseRevenueBridge$UnityPurchaseRevenueBridge") { }
|
||||||
|
|
||||||
|
public string getAdditionalParameters(string productsJson, string transactionsJson)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create empty sets if JSON is null or empty
|
||||||
|
HashSet<object> products = new HashSet<object>();
|
||||||
|
HashSet<object> transactions = new HashSet<object>();
|
||||||
|
|
||||||
|
// Only try to parse if we have valid JSON
|
||||||
|
if (!string.IsNullOrEmpty(productsJson))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// First try to parse as a simple array
|
||||||
|
var parsedProducts = AFMiniJSON.Json.Deserialize(productsJson);
|
||||||
|
if (parsedProducts is List<object> productList)
|
||||||
|
{
|
||||||
|
products = new HashSet<object>(productList);
|
||||||
|
}
|
||||||
|
else if (parsedProducts is Dictionary<string, object> dict)
|
||||||
|
{
|
||||||
|
if (dict.ContainsKey("events") && dict["events"] is List<object> eventsList)
|
||||||
|
{
|
||||||
|
products = new HashSet<object>(eventsList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If it's a dictionary but doesn't have events, add the whole dict
|
||||||
|
products.Add(dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Error parsing products JSON: {e.Message}\nJSON: {productsJson}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(transactionsJson))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// First try to parse as a simple array
|
||||||
|
var parsedTransactions = AFMiniJSON.Json.Deserialize(transactionsJson);
|
||||||
|
if (parsedTransactions is List<object> transactionList)
|
||||||
|
{
|
||||||
|
transactions = new HashSet<object>(transactionList);
|
||||||
|
}
|
||||||
|
else if (parsedTransactions is Dictionary<string, object> dict)
|
||||||
|
{
|
||||||
|
if (dict.ContainsKey("events") && dict["events"] is List<object> eventsList)
|
||||||
|
{
|
||||||
|
transactions = new HashSet<object>(eventsList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If it's a dictionary but doesn't have events, add the whole dict
|
||||||
|
transactions.Add(dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Error parsing transactions JSON: {e.Message}\nJSON: {transactionsJson}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameters = AppsFlyerPurchaseRevenueBridge.GetAdditionalParametersForAndroid(products, transactions);
|
||||||
|
return AFMiniJSON.Json.Serialize(parameters);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Error in getAdditionalParameters: {e.Message}\nProducts JSON: {productsJson}\nTransactions JSON: {transactionsJson}");
|
||||||
|
return "{}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class AppsFlyerPurchaseConnector : MonoBehaviour {
|
||||||
|
|
||||||
|
private static AppsFlyerPurchaseConnector instance;
|
||||||
|
private Dictionary<string, object> pendingParameters;
|
||||||
|
private Action<Dictionary<string, object>> pendingCallback;
|
||||||
|
|
||||||
|
public static AppsFlyerPurchaseConnector Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
GameObject go = new GameObject("AppsFlyerPurchaseConnector");
|
||||||
|
instance = go.AddComponent<AppsFlyerPurchaseConnector>();
|
||||||
|
DontDestroyOnLoad(go);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
DontDestroyOnLoad(gameObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
private static AndroidJavaClass appsFlyerAndroidConnector = new AndroidJavaClass("com.appsflyer.unity.AppsFlyerAndroidWrapper");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static void init(MonoBehaviour unityObject, Store s) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_initPurchaseConnector(unityObject.name);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
int store = mapStoreToInt(s);
|
||||||
|
appsFlyerAndroidConnector.CallStatic("initPurchaseConnector", unityObject ? unityObject.name : null, store);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void build() {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
//not for iOS
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
appsFlyerAndroidConnector.CallStatic("build");
|
||||||
|
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startObservingTransactions() {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_startObservingTransactions();
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
appsFlyerAndroidConnector.CallStatic("startObservingTransactions");
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopObservingTransactions() {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_stopObservingTransactions();
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
appsFlyerAndroidConnector.CallStatic("stopObservingTransactions");
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setIsSandbox(bool isSandbox) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_setIsSandbox(isSandbox);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
appsFlyerAndroidConnector.CallStatic("setIsSandbox", isSandbox);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPurchaseRevenueValidationListeners(bool enableCallbacks) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_setPurchaseRevenueDelegate();
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
appsFlyerAndroidConnector.CallStatic("setPurchaseRevenueValidationListeners", enableCallbacks);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAutoLogPurchaseRevenue(params AppsFlyerAutoLogPurchaseRevenueOptions[] autoLogPurchaseRevenueOptions) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
int option = 0;
|
||||||
|
foreach (AppsFlyerAutoLogPurchaseRevenueOptions op in autoLogPurchaseRevenueOptions) {
|
||||||
|
option = option | (int)op;
|
||||||
|
}
|
||||||
|
_setAutoLogPurchaseRevenue(option);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
if (autoLogPurchaseRevenueOptions.Length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (AppsFlyerAutoLogPurchaseRevenueOptions op in autoLogPurchaseRevenueOptions) {
|
||||||
|
switch(op) {
|
||||||
|
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsDisabled:
|
||||||
|
break;
|
||||||
|
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions:
|
||||||
|
appsFlyerAndroidConnector.CallStatic("setAutoLogSubscriptions", true);
|
||||||
|
break;
|
||||||
|
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsInAppPurchases:
|
||||||
|
appsFlyerAndroidConnector.CallStatic("setAutoLogInApps", true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPurchaseRevenueDataSource(IAppsFlyerPurchaseRevenueDataSource dataSource)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
|
||||||
|
if (dataSource != null)
|
||||||
|
{
|
||||||
|
_setPurchaseRevenueDataSource(dataSource.GetType().Name);
|
||||||
|
AppsFlyerPurchaseRevenueBridge.RegisterDataSource(dataSource);
|
||||||
|
}
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
if (dataSource != null)
|
||||||
|
{
|
||||||
|
AppsFlyerPurchaseRevenueBridge.RegisterDataSource(dataSource);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setPurchaseRevenueDataSourceStoreKit2(IAppsFlyerPurchaseRevenueDataSourceStoreKit2 dataSourceSK2)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
if (dataSourceSK2 != null)
|
||||||
|
{
|
||||||
|
AppsFlyerPurchaseRevenueBridge.RegisterDataSourceStoreKit2(dataSourceSK2);
|
||||||
|
_setPurchaseRevenueDataSource("AppsFlyerObjectScript_StoreKit2");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static int mapStoreToInt(Store s) {
|
||||||
|
switch(s) {
|
||||||
|
case(Store.GOOGLE):
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStoreKitVersion(StoreKitVersion storeKitVersion) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_setStoreKitVersion((int)storeKitVersion);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
// Android doesn't use StoreKit
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logConsumableTransaction(string transactionJson) {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_logConsumableTransaction(transactionJson);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
// Android doesn't use StoreKit
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _startObservingTransactions();
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _stopObservingTransactions();
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setIsSandbox(bool isSandbox);
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setPurchaseRevenueDelegate();
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setPurchaseRevenueDataSource(string dataSourceName);
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setAutoLogPurchaseRevenue(int option);
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _initPurchaseConnector(string objectName);
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setStoreKitVersion(int storeKitVersion);
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _logConsumableTransaction(string transactionJson);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
public enum Store {
|
||||||
|
GOOGLE = 0
|
||||||
|
}
|
||||||
|
public enum AppsFlyerAutoLogPurchaseRevenueOptions
|
||||||
|
{
|
||||||
|
AppsFlyerAutoLogPurchaseRevenueOptionsDisabled = 0,
|
||||||
|
AppsFlyerAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions = 1 << 0,
|
||||||
|
AppsFlyerAutoLogPurchaseRevenueOptionsInAppPurchases = 1 << 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum StoreKitVersion {
|
||||||
|
SK1 = 0,
|
||||||
|
SK2 = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0636ea07d370d437183f3762280c08ce
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
namespace AppsFlyerSDK
|
||||||
|
{
|
||||||
|
public interface IAppsFlyerPurchaseValidation
|
||||||
|
{
|
||||||
|
void didReceivePurchaseRevenueValidationInfo(string validationInfo);
|
||||||
|
void didReceivePurchaseRevenueError(string error);
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7c60f499ae0d048b1be8ffd6878a184c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
+184
@@ -0,0 +1,184 @@
|
|||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class InAppPurchaseValidationResult : EventArgs
|
||||||
|
{
|
||||||
|
public bool success;
|
||||||
|
public ProductPurchase? productPurchase;
|
||||||
|
public ValidationFailureData? failureData;
|
||||||
|
public string? token;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ProductPurchase
|
||||||
|
{
|
||||||
|
public string? kind;
|
||||||
|
public string? purchaseTimeMillis;
|
||||||
|
public int purchaseState;
|
||||||
|
public int consumptionState;
|
||||||
|
public string? developerPayload;
|
||||||
|
public string? orderId;
|
||||||
|
public int purchaseType;
|
||||||
|
public int acknowledgementState;
|
||||||
|
public string? purchaseToken;
|
||||||
|
public string? productId;
|
||||||
|
public int quantity;
|
||||||
|
public string? obfuscatedExternalAccountId;
|
||||||
|
public string? obfuscatedExternalProfil;
|
||||||
|
public string? regionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ValidationFailureData
|
||||||
|
{
|
||||||
|
public int status;
|
||||||
|
public string? description;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubscriptionValidationResult
|
||||||
|
{
|
||||||
|
public bool success;
|
||||||
|
public SubscriptionPurchase? subscriptionPurchase;
|
||||||
|
public ValidationFailureData? failureData;
|
||||||
|
public string? token;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubscriptionPurchase
|
||||||
|
{
|
||||||
|
public string? acknowledgementState;
|
||||||
|
public CanceledStateContext? canceledStateContext;
|
||||||
|
public ExternalAccountIdentifiers? externalAccountIdentifiers;
|
||||||
|
public string? kind;
|
||||||
|
public string? latestOrderId;
|
||||||
|
public List<SubscriptionPurchaseLineItem>? lineItems;
|
||||||
|
public string? linkedPurchaseToken;
|
||||||
|
public PausedStateContext? pausedStateContext;
|
||||||
|
public string? regionCode;
|
||||||
|
public string? startTime;
|
||||||
|
public SubscribeWithGoogleInfo? subscribeWithGoogleInfo;
|
||||||
|
public string? subscriptionState;
|
||||||
|
public TestPurchase? testPurchase;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class CanceledStateContext
|
||||||
|
{
|
||||||
|
public DeveloperInitiatedCancellation? developerInitiatedCancellation;
|
||||||
|
public ReplacementCancellation? replacementCancellation;
|
||||||
|
public SystemInitiatedCancellation? systemInitiatedCancellation;
|
||||||
|
public UserInitiatedCancellation? userInitiatedCancellation;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ExternalAccountIdentifiers
|
||||||
|
{
|
||||||
|
public string? externalAccountId;
|
||||||
|
public string? obfuscatedExternalAccountId;
|
||||||
|
public string? obfuscatedExternalProfileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubscriptionPurchaseLineItem
|
||||||
|
{
|
||||||
|
public AutoRenewingPlan? autoRenewingPlan;
|
||||||
|
public DeferredItemReplacement? deferredItemReplacement;
|
||||||
|
public string? expiryTime;
|
||||||
|
public OfferDetails? offerDetails;
|
||||||
|
public PrepaidPlan? prepaidPlan;
|
||||||
|
public string? productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PausedStateContext
|
||||||
|
{
|
||||||
|
public string? autoResumeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubscribeWithGoogleInfo
|
||||||
|
{
|
||||||
|
public string? emailAddress;
|
||||||
|
public string? familyName;
|
||||||
|
public string? givenName;
|
||||||
|
public string? profileId;
|
||||||
|
public string? profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class TestPurchase{}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class DeveloperInitiatedCancellation{}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ReplacementCancellation{}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SystemInitiatedCancellation{}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class UserInitiatedCancellation
|
||||||
|
{
|
||||||
|
public CancelSurveyResult? cancelSurveyResult;
|
||||||
|
public string? cancelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class AutoRenewingPlan
|
||||||
|
{
|
||||||
|
public string? autoRenewEnabled;
|
||||||
|
public SubscriptionItemPriceChangeDetails? priceChangeDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class DeferredItemReplacement
|
||||||
|
{
|
||||||
|
public string? productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class OfferDetails
|
||||||
|
{
|
||||||
|
public List<string>? offerTags;
|
||||||
|
public string? basePlanId;
|
||||||
|
public string? offerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PrepaidPlan
|
||||||
|
{
|
||||||
|
public string? allowExtendAfterTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class CancelSurveyResult
|
||||||
|
{
|
||||||
|
public string? reason;
|
||||||
|
public string? reasonUserInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SubscriptionItemPriceChangeDetails
|
||||||
|
{
|
||||||
|
public string? expectedNewPriceChargeTime;
|
||||||
|
public Money? newPrice;
|
||||||
|
public string? priceChangeMode;
|
||||||
|
public string? priceChangeState;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class Money
|
||||||
|
{
|
||||||
|
public string? currencyCode;
|
||||||
|
public long nanos;
|
||||||
|
public long units;
|
||||||
|
}
|
||||||
|
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a1435104a69d4c8ebcc6f237cc29a54
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+3
-3
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"name": "BigoAds"
|
"name": "BigoAds"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+106
-106
@@ -1,106 +1,106 @@
|
|||||||
package sg.bigo.ads;
|
package sg.bigo.ads;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import sg.bigo.ads.api.AdOptionsView;
|
import sg.bigo.ads.api.AdOptionsView;
|
||||||
import sg.bigo.ads.api.AdTag;
|
import sg.bigo.ads.api.AdTag;
|
||||||
import sg.bigo.ads.api.MediaView;
|
import sg.bigo.ads.api.MediaView;
|
||||||
import sg.bigo.ads.api.NativeAd;
|
import sg.bigo.ads.api.NativeAd;
|
||||||
|
|
||||||
public class AdHelper {
|
public class AdHelper {
|
||||||
|
|
||||||
public static void postToAndroidMainThread(Runnable runnable) {
|
public static void postToAndroidMainThread(Runnable runnable) {
|
||||||
new Handler(Looper.getMainLooper()).post(runnable);
|
new Handler(Looper.getMainLooper()).post(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAdView(Activity activity, View adView, int position) {
|
public static void addAdView(Activity activity, View adView, int position) {
|
||||||
if (adView == null) return;
|
if (adView == null) return;
|
||||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||||
String tag = "ad_container";
|
String tag = "ad_container";
|
||||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||||
if (adContainer == null) {
|
if (adContainer == null) {
|
||||||
adContainer = new FrameLayout(activity);
|
adContainer = new FrameLayout(activity);
|
||||||
adContainer.setTag(tag);
|
adContainer.setTag(tag);
|
||||||
}
|
}
|
||||||
contentView.removeView(adContainer);
|
contentView.removeView(adContainer);
|
||||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, position);
|
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, position);
|
||||||
contentView.addView(adContainer, layoutParams);
|
contentView.addView(adContainer, layoutParams);
|
||||||
adContainer.removeAllViews();
|
adContainer.removeAllViews();
|
||||||
adContainer.addView(adView);
|
adContainer.addView(adView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAdView(Activity activity)
|
public static void removeAdView(Activity activity)
|
||||||
{
|
{
|
||||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||||
String tag = "ad_container";
|
String tag = "ad_container";
|
||||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||||
if (adContainer == null) return;
|
if (adContainer == null) return;
|
||||||
adContainer.removeAllViews();
|
adContainer.removeAllViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLayoutIdByResName(Activity activity, String resName) {
|
public static int getLayoutIdByResName(Activity activity, String resName) {
|
||||||
return activity.getResources().getIdentifier(resName, "layout", activity.getPackageName());
|
return activity.getResources().getIdentifier(resName, "layout", activity.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDrawableIdByResName(Activity activity, String resName) {
|
public static int getDrawableIdByResName(Activity activity, String resName) {
|
||||||
return activity.getResources().getIdentifier(resName, "drawable", activity.getPackageName());
|
return activity.getResources().getIdentifier(resName, "drawable", activity.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static View renderNativeAdView(Activity activity, NativeAd nativeAd, String layoutResName) {
|
public static View renderNativeAdView(Activity activity, NativeAd nativeAd, String layoutResName) {
|
||||||
int layoutId = getLayoutIdByResName(activity, layoutResName);
|
int layoutId = getLayoutIdByResName(activity, layoutResName);
|
||||||
if (layoutId <= 0) {
|
if (layoutId <= 0) {
|
||||||
Log.w("BigoAds-Unity", "Invalid res name: " + layoutResName);
|
Log.w("BigoAds-Unity", "Invalid res name: " + layoutResName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
View view = LayoutInflater.from(activity).inflate(layoutId, null, false);
|
View view = LayoutInflater.from(activity).inflate(layoutId, null, false);
|
||||||
if (!(view instanceof ViewGroup)) {
|
if (!(view instanceof ViewGroup)) {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
ViewGroup nativeView = (ViewGroup) view;
|
ViewGroup nativeView = (ViewGroup) view;
|
||||||
TextView titleView = findViewByIdName(nativeView, "native_title");
|
TextView titleView = findViewByIdName(nativeView, "native_title");
|
||||||
TextView descriptionView = findViewByIdName(nativeView, "native_description");
|
TextView descriptionView = findViewByIdName(nativeView, "native_description");
|
||||||
TextView warningView = findViewByIdName(nativeView, "native_warning");
|
TextView warningView = findViewByIdName(nativeView, "native_warning");
|
||||||
Button ctaButton = findViewByIdName(nativeView, "native_cta");
|
Button ctaButton = findViewByIdName(nativeView, "native_cta");
|
||||||
MediaView mediaView = findViewByIdName(nativeView, "native_media_view");
|
MediaView mediaView = findViewByIdName(nativeView, "native_media_view");
|
||||||
ImageView iconView = findViewByIdName(nativeView, "native_icon_view");
|
ImageView iconView = findViewByIdName(nativeView, "native_icon_view");
|
||||||
AdOptionsView optionsView = findViewByIdName(nativeView, "native_option_view");
|
AdOptionsView optionsView = findViewByIdName(nativeView, "native_option_view");
|
||||||
|
|
||||||
titleView.setTag(AdTag.TITLE);
|
titleView.setTag(AdTag.TITLE);
|
||||||
descriptionView.setTag(AdTag.DESCRIPTION);
|
descriptionView.setTag(AdTag.DESCRIPTION);
|
||||||
warningView.setTag(AdTag.WARNING);
|
warningView.setTag(AdTag.WARNING);
|
||||||
ctaButton.setTag(AdTag.CALL_TO_ACTION);
|
ctaButton.setTag(AdTag.CALL_TO_ACTION);
|
||||||
|
|
||||||
titleView.setText(nativeAd.getTitle());
|
titleView.setText(nativeAd.getTitle());
|
||||||
descriptionView.setText(nativeAd.getDescription());
|
descriptionView.setText(nativeAd.getDescription());
|
||||||
warningView.setText(nativeAd.getWarning());
|
warningView.setText(nativeAd.getWarning());
|
||||||
ctaButton.setText(nativeAd.getCallToAction());
|
ctaButton.setText(nativeAd.getCallToAction());
|
||||||
|
|
||||||
List<View> clickableViews = new ArrayList<>();
|
List<View> clickableViews = new ArrayList<>();
|
||||||
clickableViews.add(titleView);
|
clickableViews.add(titleView);
|
||||||
clickableViews.add(descriptionView);
|
clickableViews.add(descriptionView);
|
||||||
clickableViews.add(ctaButton);
|
clickableViews.add(ctaButton);
|
||||||
nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews);
|
nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews);
|
||||||
return nativeView;
|
return nativeView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends View> T findViewByIdName(ViewGroup parent, String name) {
|
private static <T extends View> T findViewByIdName(ViewGroup parent, String name) {
|
||||||
Context context = parent.getContext();
|
Context context = parent.getContext();
|
||||||
int id = context.getResources().getIdentifier(name, "id", context.getPackageName());
|
int id = context.getResources().getIdentifier(name, "id", context.getPackageName());
|
||||||
return parent.findViewById(id);
|
return parent.findViewById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+13
-13
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<iosPods>
|
<iosPods>
|
||||||
<iosPod name="BigoADS" version="5.1.2"/>
|
<iosPod name="BigoADS" version="5.1.2"/>
|
||||||
</iosPods>
|
</iosPods>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="com.bigossp:bigo-ads:5.3.0">
|
<androidPackage spec="com.bigossp:bigo-ads:5.3.0">
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>https://repo1.maven.org/maven2/</repository>
|
<repository>https://repo1.maven.org/maven2/</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</androidPackage>
|
</androidPackage>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+104
-104
@@ -1,104 +1,104 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<sg.bigo.ads.api.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
|
<sg.bigo.ads.api.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/native_ad_view"
|
android:id="@+id/native_ad_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/white"
|
android:background="@android:color/white"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
tools:ignore="ContentDescription">
|
tools:ignore="ContentDescription">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/native_ad_label"
|
android:id="@+id/native_ad_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:text="Ad" />
|
android:text="Ad" />
|
||||||
|
|
||||||
<sg.bigo.ads.api.MediaView
|
<sg.bigo.ads.api.MediaView
|
||||||
android:id="@+id/native_media_view"
|
android:id="@+id/native_media_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/native_ad_label"
|
android:layout_below="@id/native_ad_label"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginTop="4dp" />
|
android:layout_marginTop="4dp" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/native_icon_view"
|
android:id="@+id/native_icon_view"
|
||||||
android:layout_width="42dp"
|
android:layout_width="42dp"
|
||||||
android:layout_height="42dp"
|
android:layout_height="42dp"
|
||||||
android:layout_below="@id/native_media_view"
|
android:layout_below="@id/native_media_view"
|
||||||
android:layout_marginTop="8dp" />
|
android:layout_marginTop="8dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/native_title"
|
android:id="@+id/native_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@id/native_icon_view"
|
android:layout_alignTop="@id/native_icon_view"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
android:layout_toEndOf="@id/native_icon_view"
|
android:layout_toEndOf="@id/native_icon_view"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:fontFamily="sans-serif-medium"
|
android:fontFamily="sans-serif-medium"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="@android:color/darker_gray"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/native_description"
|
android:id="@+id/native_description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/native_title"
|
android:layout_below="@id/native_title"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_toEndOf="@id/native_icon_view"
|
android:layout_toEndOf="@id/native_icon_view"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="@android:color/darker_gray"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/native_cta"
|
android:id="@+id/native_cta"
|
||||||
android:layout_width="240dp"
|
android:layout_width="240dp"
|
||||||
android:layout_height="44dp"
|
android:layout_height="44dp"
|
||||||
android:layout_below="@id/native_icon_view"
|
android:layout_below="@id/native_icon_view"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:backgroundTint="@android:color/holo_blue_light"
|
android:backgroundTint="@android:color/holo_blue_light"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tools:ignore="ObsoleteLayoutParam" />
|
tools:ignore="ObsoleteLayoutParam" />
|
||||||
|
|
||||||
<sg.bigo.ads.api.AdOptionsView
|
<sg.bigo.ads.api.AdOptionsView
|
||||||
android:id="@+id/native_option_view"
|
android:id="@+id/native_option_view"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_alignTop="@id/native_icon_view"
|
android:layout_alignTop="@id/native_icon_view"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginEnd="8dp" />
|
android:layout_marginEnd="8dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/native_warning"
|
android:id="@+id/native_warning"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@id/native_ad_label"
|
android:layout_alignTop="@id/native_ad_label"
|
||||||
android:layout_alignBottom="@id/native_ad_label"
|
android:layout_alignBottom="@id/native_ad_label"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_toEndOf="@id/native_ad_label"
|
android:layout_toEndOf="@id/native_ad_label"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="@android:color/darker_gray"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</sg.bigo.ads.api.NativeAdView>
|
</sg.bigo.ads.api.NativeAdView>
|
||||||
|
|||||||
Assets/MYp0ZVTT2QSDK/ThirdParty/BigoAdsAll/Plugins/Android/res/layout/layout_bigo_native_ad.xml.meta
Vendored
Regular → Executable
+11
-11
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<androidPackages>
|
<androidPackages>
|
||||||
<androidPackage spec="androidx.media3:media3-exoplayer:1.0.0-alpha01" />
|
<androidPackage spec="androidx.media3:media3-exoplayer:1.0.0-alpha01" />
|
||||||
<androidPackage spec="androidx.appcompat:appcompat:1.2.0"/>
|
<androidPackage spec="androidx.appcompat:appcompat:1.2.0"/>
|
||||||
<androidPackage spec="com.google.android.material:material:1.2.1"/>
|
<androidPackage spec="com.google.android.material:material:1.2.1"/>
|
||||||
<androidPackage spec="androidx.annotation:annotation:1.2.0"/>
|
<androidPackage spec="androidx.annotation:annotation:1.2.0"/>
|
||||||
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
|
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
|
||||||
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.0.1"/>
|
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.0.1"/>
|
||||||
</androidPackages>
|
</androidPackages>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using KwaiAds.Scripts.Common;
|
using KwaiAds.Scripts.Common;
|
||||||
|
|
||||||
namespace KwaiAds.Scripts.Api
|
namespace KwaiAds.Scripts.Api
|
||||||
|
|||||||
Vendored
Regular → Executable
+21
-21
@@ -1,21 +1,21 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public interface IKwaiAdListener
|
public interface IKwaiAdListener
|
||||||
{
|
{
|
||||||
void OnLoaded(string unitId, string price);
|
void OnLoaded(string unitId, string price);
|
||||||
|
|
||||||
void OnLoadFailed(string unitId, int code, string msg);
|
void OnLoadFailed(string unitId, int code, string msg);
|
||||||
|
|
||||||
void OnShow();
|
void OnShow();
|
||||||
|
|
||||||
void OnShowFailed(int code, string msg);
|
void OnShowFailed(int code, string msg);
|
||||||
|
|
||||||
void OnClick();
|
void OnClick();
|
||||||
|
|
||||||
void OnClosed();
|
void OnClosed();
|
||||||
|
|
||||||
void OnReward();
|
void OnReward();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
Regular → Executable
+3
-3
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"name": "KwaiAds"
|
"name": "KwaiAds"
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-66
@@ -1,66 +1,66 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class KwaiAdsMgr
|
public class KwaiAdsMgr
|
||||||
{
|
{
|
||||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||||
{
|
{
|
||||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||||
.SetAppId(appId) // ±ØÌî
|
.SetAppId(appId) // ±ØÌî
|
||||||
.SetToken(token) // ±ØÌî
|
.SetToken(token) // ±ØÌî
|
||||||
.SetAppName("")
|
.SetAppName("")
|
||||||
.SetAppDomain("")
|
.SetAppDomain("")
|
||||||
.SetAppStoreUrl("")
|
.SetAppStoreUrl("")
|
||||||
.SetDebugLog(debug)
|
.SetDebugLog(debug)
|
||||||
.Build();
|
.Build();
|
||||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||||
{
|
{
|
||||||
private Action<bool, int, string> _initCallBack;
|
private Action<bool, int, string> _initCallBack;
|
||||||
|
|
||||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||||
{
|
{
|
||||||
_initCallBack = callBack;
|
_initCallBack = callBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnFail(int code, string msg)
|
public void OnFail(int code, string msg)
|
||||||
{
|
{
|
||||||
_initCallBack?.Invoke(false, code, msg);
|
_initCallBack?.Invoke(false, code, msg);
|
||||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSuccess()
|
public void OnSuccess()
|
||||||
{
|
{
|
||||||
_initCallBack?.Invoke(true, 0, "");
|
_initCallBack?.Invoke(true, 0, "");
|
||||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class KwaiLog
|
public class KwaiLog
|
||||||
{
|
{
|
||||||
public static bool isShow = true;
|
public static bool isShow = true;
|
||||||
|
|
||||||
public static void Log(string msg)
|
public static void Log(string msg)
|
||||||
{
|
{
|
||||||
if (isShow)
|
if (isShow)
|
||||||
{
|
{
|
||||||
Debug.Log(msg);
|
Debug.Log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Error(string msg)
|
public static void Error(string msg)
|
||||||
{
|
{
|
||||||
if (isShow)
|
if (isShow)
|
||||||
{
|
{
|
||||||
Debug.LogError(msg);
|
Debug.LogError(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+133
-133
@@ -1,133 +1,133 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using KwaiAds.Scripts.Api;
|
using KwaiAds.Scripts.Api;
|
||||||
using KwaiAds.Scripts.Api.Interstitial;
|
using KwaiAds.Scripts.Api.Interstitial;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class KwaiInterAd
|
public class KwaiInterAd
|
||||||
{
|
{
|
||||||
private IInterstitialAdController _kwaiInter;
|
private IInterstitialAdController _kwaiInter;
|
||||||
private string _unitId;
|
private string _unitId;
|
||||||
private IKwaiAdListener _kwaiAdListener;
|
private IKwaiAdListener _kwaiAdListener;
|
||||||
|
|
||||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||||
|
|
||||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||||
{
|
{
|
||||||
_unitId = unitId;
|
_unitId = unitId;
|
||||||
_kwaiAdListener = adListener;
|
_kwaiAdListener = adListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load(string ecpmPrice = "0.01")
|
public void Load(string ecpmPrice = "0.01")
|
||||||
{
|
{
|
||||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||||
if (_kwaiInter != null)
|
if (_kwaiInter != null)
|
||||||
{
|
{
|
||||||
_kwaiInter.Destroy();
|
_kwaiInter.Destroy();
|
||||||
_kwaiInter = null;
|
_kwaiInter = null;
|
||||||
}
|
}
|
||||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||||
// 构建KwaiInterstitialAdRequest
|
// 构建KwaiInterstitialAdRequest
|
||||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||||
// 加载过程接受三个参数,
|
// 加载过程接受三个参数,
|
||||||
// - KwaiInterstitialAdRequest 配置请求参数
|
// - KwaiInterstitialAdRequest 配置请求参数
|
||||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public void Show()
|
||||||
{
|
{
|
||||||
if (IsReady())
|
if (IsReady())
|
||||||
{
|
{
|
||||||
_kwaiInter.Show();
|
_kwaiInter.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool IsReady()
|
public bool IsReady()
|
||||||
{
|
{
|
||||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyWin(string minWinPrice)
|
public void NotifyWin(string minWinPrice)
|
||||||
{
|
{
|
||||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||||
_kwaiInter?.NotifyWin(minWinPrice);
|
_kwaiInter?.NotifyWin(minWinPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyLoss(string winPrice)
|
public void NotifyLoss(string winPrice)
|
||||||
{
|
{
|
||||||
//_kwaiInter?.NotifyLoss();
|
//_kwaiInter?.NotifyLoss();
|
||||||
_kwaiInter?.NotifyLoss(winPrice);
|
_kwaiInter?.NotifyLoss(winPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InterstitialAdListener : IInterstitialAdListener
|
private class InterstitialAdListener : IInterstitialAdListener
|
||||||
{
|
{
|
||||||
private KwaiInterAd _kwaiInterAd;
|
private KwaiInterAd _kwaiInterAd;
|
||||||
|
|
||||||
public InterstitialAdListener(KwaiInterAd interAd)
|
public InterstitialAdListener(KwaiInterAd interAd)
|
||||||
{
|
{
|
||||||
_kwaiInterAd = interAd;
|
_kwaiInterAd = interAd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdClick()
|
public void OnAdClick()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdClick");
|
KwaiLog.Log($"#Kwai OnAdClick");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdClose()
|
public void OnAdClose()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdClose");
|
KwaiLog.Log($"#Kwai OnAdClose");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdPlayComplete()
|
public void OnAdPlayComplete()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdShow()
|
public void OnAdShow()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdShow");
|
KwaiLog.Log($"#Kwai OnAdShow");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdShowFailed(int code, string msg)
|
public void OnAdShowFailed(int code, string msg)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||||
{
|
{
|
||||||
private KwaiInterAd _kwaiInterAd;
|
private KwaiInterAd _kwaiInterAd;
|
||||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||||
{
|
{
|
||||||
_kwaiInterAd = interAd;
|
_kwaiInterAd = interAd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadStart(string trackId)
|
public void OnAdLoadStart(string trackId)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadSuccess(string trackId, string price)
|
public void OnAdLoadSuccess(string trackId, string price)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+139
-139
@@ -1,139 +1,139 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using KwaiAds.Scripts.Api.Reward;
|
using KwaiAds.Scripts.Api.Reward;
|
||||||
using KwaiAds.Scripts.Api;
|
using KwaiAds.Scripts.Api;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class KwaiVideoAd
|
public class KwaiVideoAd
|
||||||
{
|
{
|
||||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||||
private string _unitId;
|
private string _unitId;
|
||||||
private IKwaiAdListener _kwaiAdListener;
|
private IKwaiAdListener _kwaiAdListener;
|
||||||
|
|
||||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||||
|
|
||||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||||
{
|
{
|
||||||
_unitId = unitId;
|
_unitId = unitId;
|
||||||
_kwaiAdListener = adListener;
|
_kwaiAdListener = adListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load(string ecpmPrice = "0.01")
|
public void Load(string ecpmPrice = "0.01")
|
||||||
{
|
{
|
||||||
if(_kwaiReward != null)
|
if(_kwaiReward != null)
|
||||||
{
|
{
|
||||||
_kwaiReward.Destroy();
|
_kwaiReward.Destroy();
|
||||||
_kwaiReward = null;
|
_kwaiReward = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||||
|
|
||||||
// 构建KwaiRewardAdRequest
|
// 构建KwaiRewardAdRequest
|
||||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||||
// 加载过程接受三个参数,
|
// 加载过程接受三个参数,
|
||||||
// - KwaiRewardAdRequest 配置请求参数
|
// - KwaiRewardAdRequest 配置请求参数
|
||||||
// - IRewardAdListener实现类,回调为激励
|
// - IRewardAdListener实现类,回调为激励
|
||||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public void Show()
|
||||||
{
|
{
|
||||||
if(IsReady())
|
if(IsReady())
|
||||||
{
|
{
|
||||||
_kwaiReward.Show();
|
_kwaiReward.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsReady()
|
public bool IsReady()
|
||||||
{
|
{
|
||||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyWin(string minWinPrice)
|
public void NotifyWin(string minWinPrice)
|
||||||
{
|
{
|
||||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||||
_kwaiReward?.NotifyWin(minWinPrice);
|
_kwaiReward?.NotifyWin(minWinPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyLoss(string winPrice)
|
public void NotifyLoss(string winPrice)
|
||||||
{
|
{
|
||||||
//_kwaiReward?.NotifyLoss();
|
//_kwaiReward?.NotifyLoss();
|
||||||
_kwaiReward?.NotifyLoss(winPrice);
|
_kwaiReward?.NotifyLoss(winPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class RewardAdListener : IRewardAdListener
|
private class RewardAdListener : IRewardAdListener
|
||||||
{
|
{
|
||||||
private KwaiVideoAd _kwaiVideoAd;
|
private KwaiVideoAd _kwaiVideoAd;
|
||||||
|
|
||||||
public RewardAdListener(KwaiVideoAd videoAd)
|
public RewardAdListener(KwaiVideoAd videoAd)
|
||||||
{
|
{
|
||||||
_kwaiVideoAd = videoAd;
|
_kwaiVideoAd = videoAd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdClick()
|
public void OnAdClick()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdClick");
|
KwaiLog.Log($"#Kwai OnAdClick");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdClose()
|
public void OnAdClose()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdClose");
|
KwaiLog.Log($"#Kwai OnAdClose");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdPlayComplete()
|
public void OnAdPlayComplete()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdShow()
|
public void OnAdShow()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdShow");
|
KwaiLog.Log($"#Kwai OnAdShow");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdShowFailed(int code, string msg)
|
public void OnAdShowFailed(int code, string msg)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRewardEarned()
|
public void OnRewardEarned()
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||||
{
|
{
|
||||||
private KwaiVideoAd _kwaiVideoAd;
|
private KwaiVideoAd _kwaiVideoAd;
|
||||||
|
|
||||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||||
{
|
{
|
||||||
_kwaiVideoAd = videoAd;
|
_kwaiVideoAd = videoAd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadStart(string trackId)
|
public void OnAdLoadStart(string trackId)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAdLoadSuccess(string trackId, string price)
|
public void OnAdLoadSuccess(string trackId, string price)
|
||||||
{
|
{
|
||||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
|||||||
public void NotifyLoss(string winPrice)
|
public void NotifyLoss(string winPrice)
|
||||||
{
|
{
|
||||||
if (_KwaiInterstitialAd != null)
|
if (_KwaiInterstitialAd != null)
|
||||||
{
|
{
|
||||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidLose");
|
//_KwaiInterstitialAd.Call("getBidController", "sendBidLose");
|
||||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||||
bidController?.Call("sendBidLose", "101", winPrice);
|
bidController?.Call("sendBidLose", "101", winPrice);
|
||||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
|||||||
public void NotifyWin(string minWinPrice)
|
public void NotifyWin(string minWinPrice)
|
||||||
{
|
{
|
||||||
if (_KwaiInterstitialAd != null)
|
if (_KwaiInterstitialAd != null)
|
||||||
{
|
{
|
||||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidWin");
|
//_KwaiInterstitialAd.Call("getBidController", "sendBidWin");
|
||||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||||
bidController?.Call("sendBidWin", minWinPrice);
|
bidController?.Call("sendBidWin", minWinPrice);
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
|||||||
public void NotifyLoss(string winPrice)
|
public void NotifyLoss(string winPrice)
|
||||||
{
|
{
|
||||||
if (_KwaiRewardAd != null)
|
if (_KwaiRewardAd != null)
|
||||||
{
|
{
|
||||||
//_KwaiRewardAd.Call("getBidController", "sendBidLose");
|
//_KwaiRewardAd.Call("getBidController", "sendBidLose");
|
||||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||||
bidController?.Call("sendBidLose", "101", winPrice);
|
bidController?.Call("sendBidLose", "101", winPrice);
|
||||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
|||||||
public void NotifyWin(string minWinPrice)
|
public void NotifyWin(string minWinPrice)
|
||||||
{
|
{
|
||||||
if (_KwaiRewardAd != null)
|
if (_KwaiRewardAd != null)
|
||||||
{
|
{
|
||||||
//_KwaiRewardAd.Call("getBidController", "sendBidWin");
|
//_KwaiRewardAd.Call("getBidController", "sendBidWin");
|
||||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||||
bidController?.Call("sendBidWin", minWinPrice);
|
bidController?.Call("sendBidWin", minWinPrice);
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+124
-124
@@ -1,125 +1,125 @@
|
|||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Android;
|
using UnityEditor.Android;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class BuildPostProcessorVoSdk : IPostGenerateGradleAndroidProject
|
public class BuildPostProcessorVoSdk : IPostGenerateGradleAndroidProject
|
||||||
{
|
{
|
||||||
public int callbackOrder => 0;
|
public int callbackOrder => 0;
|
||||||
|
|
||||||
public void OnPostGenerateGradleAndroidProject(string path)
|
public void OnPostGenerateGradleAndroidProject(string path)
|
||||||
{
|
{
|
||||||
Debug.Log("AndroidBuildPostProcessor running after gradle project generation");
|
Debug.Log("AndroidBuildPostProcessor running after gradle project generation");
|
||||||
|
|
||||||
// 添加AndroidManifest权限
|
// 添加AndroidManifest权限
|
||||||
AddManifestPermissions(path);
|
AddManifestPermissions(path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddManifestPermissions(string gradleProjectPath)
|
private void AddManifestPermissions(string gradleProjectPath)
|
||||||
{
|
{
|
||||||
string manifestPath = Path.Combine(gradleProjectPath, "src/main/AndroidManifest.xml");
|
string manifestPath = Path.Combine(gradleProjectPath, "src/main/AndroidManifest.xml");
|
||||||
if (!File.Exists(manifestPath))
|
if (!File.Exists(manifestPath))
|
||||||
{
|
{
|
||||||
Debug.LogError("AndroidManifest.xml not found at: " + manifestPath);
|
Debug.LogError("AndroidManifest.xml not found at: " + manifestPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(manifestPath);
|
doc.Load(manifestPath);
|
||||||
|
|
||||||
// 更可靠的方式查找 manifest 节点
|
// 更可靠的方式查找 manifest 节点
|
||||||
XmlNode manifestNode = doc.SelectSingleNode("//manifest");
|
XmlNode manifestNode = doc.SelectSingleNode("//manifest");
|
||||||
if (manifestNode == null)
|
if (manifestNode == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("No manifest node found in AndroidManifest.xml");
|
Debug.LogError("No manifest node found in AndroidManifest.xml");
|
||||||
Debug.Log("Trying to parse document element as manifest...");
|
Debug.Log("Trying to parse document element as manifest...");
|
||||||
manifestNode = doc.DocumentElement;
|
manifestNode = doc.DocumentElement;
|
||||||
if (manifestNode == null || manifestNode.Name != "manifest")
|
if (manifestNode == null || manifestNode.Name != "manifest")
|
||||||
{
|
{
|
||||||
Debug.LogError("Failed to find manifest node, document element is: " +
|
Debug.LogError("Failed to find manifest node, document element is: " +
|
||||||
(manifestNode?.Name ?? "null"));
|
(manifestNode?.Name ?? "null"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 要添加的权限列表
|
// 要添加的权限列表
|
||||||
string[] permissions = new string[]
|
string[] permissions = new string[]
|
||||||
{
|
{
|
||||||
"android.permission.INTERNET",
|
"android.permission.INTERNET",
|
||||||
"android.permission.ACCESS_NETWORK_STATE",
|
"android.permission.ACCESS_NETWORK_STATE",
|
||||||
"android.permission.ACCESS_WIFI_STATE",
|
"android.permission.ACCESS_WIFI_STATE",
|
||||||
"android.permission.WAKE_LOCK",
|
"android.permission.WAKE_LOCK",
|
||||||
//"android.permission.WRITE_EXTERNAL_STORAGE",
|
//"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||||
//"android.permission.READ_PHONE_STATE",
|
//"android.permission.READ_PHONE_STATE",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加权限
|
// 添加权限
|
||||||
foreach (var permission in permissions)
|
foreach (var permission in permissions)
|
||||||
{
|
{
|
||||||
if (!PermissionExists(doc, permission))
|
if (!PermissionExists(doc, permission))
|
||||||
{
|
{
|
||||||
XmlElement element = doc.CreateElement("uses-permission");
|
XmlElement element = doc.CreateElement("uses-permission");
|
||||||
element.SetAttribute("name", "http://schemas.android.com/apk/res/android", permission);
|
element.SetAttribute("name", "http://schemas.android.com/apk/res/android", permission);
|
||||||
manifestNode.AppendChild(element);
|
manifestNode.AppendChild(element);
|
||||||
Debug.Log("Added permission: " + permission);
|
Debug.Log("Added permission: " + permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加queries
|
// 添加queries
|
||||||
AddQueriesIfNeeded(doc, manifestNode);
|
AddQueriesIfNeeded(doc, manifestNode);
|
||||||
|
|
||||||
// 保存修改
|
// 保存修改
|
||||||
doc.Save(manifestPath);
|
doc.Save(manifestPath);
|
||||||
Debug.Log("Successfully updated AndroidManifest.xml");
|
Debug.Log("Successfully updated AndroidManifest.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool PermissionExists(XmlDocument doc, string permissionName)
|
private bool PermissionExists(XmlDocument doc, string permissionName)
|
||||||
{
|
{
|
||||||
XmlNodeList nodes = doc.GetElementsByTagName("uses-permission");
|
XmlNodeList nodes = doc.GetElementsByTagName("uses-permission");
|
||||||
foreach (XmlNode node in nodes)
|
foreach (XmlNode node in nodes)
|
||||||
{
|
{
|
||||||
var nameAttr = node.Attributes?["android:name"];
|
var nameAttr = node.Attributes?["android:name"];
|
||||||
if (nameAttr != null && nameAttr.Value == permissionName)
|
if (nameAttr != null && nameAttr.Value == permissionName)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddQueriesIfNeeded(XmlDocument doc, XmlNode manifestNode)
|
private void AddQueriesIfNeeded(XmlDocument doc, XmlNode manifestNode)
|
||||||
{
|
{
|
||||||
// 检查是否已存在queries节点
|
// 检查是否已存在queries节点
|
||||||
XmlNode queriesNode = doc.SelectSingleNode("//queries");
|
XmlNode queriesNode = doc.SelectSingleNode("//queries");
|
||||||
if (queriesNode != null) return;
|
if (queriesNode != null) return;
|
||||||
|
|
||||||
// 创建queries节点
|
// 创建queries节点
|
||||||
queriesNode = doc.CreateElement("queries");
|
queriesNode = doc.CreateElement("queries");
|
||||||
|
|
||||||
// 添加package节点
|
// 添加package节点
|
||||||
string[] packages = { "com.android.vending", "com.google.android.gms" };
|
string[] packages = { "com.android.vending", "com.google.android.gms" };
|
||||||
foreach (var package in packages)
|
foreach (var package in packages)
|
||||||
{
|
{
|
||||||
XmlElement packageElement = doc.CreateElement("package");
|
XmlElement packageElement = doc.CreateElement("package");
|
||||||
packageElement.SetAttribute("name", "http://schemas.android.com/apk/res/android", package);
|
packageElement.SetAttribute("name", "http://schemas.android.com/apk/res/android", package);
|
||||||
queriesNode.AppendChild(packageElement);
|
queriesNode.AppendChild(packageElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将queries节点添加到manifest中(application节点之前)
|
// 将queries节点添加到manifest中(application节点之前)
|
||||||
XmlNode applicationNode = doc.SelectSingleNode("//application");
|
XmlNode applicationNode = doc.SelectSingleNode("//application");
|
||||||
if (applicationNode != null)
|
if (applicationNode != null)
|
||||||
{
|
{
|
||||||
manifestNode.InsertBefore(queriesNode, applicationNode);
|
manifestNode.InsertBefore(queriesNode, applicationNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
manifestNode.AppendChild(queriesNode);
|
manifestNode.AppendChild(queriesNode);
|
||||||
}
|
}
|
||||||
Debug.Log("Added queries section to AndroidManifest.xml");
|
Debug.Log("Added queries section to AndroidManifest.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Vendored
Regular → Executable
+20
-20
@@ -1,20 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AD.VosacoSDK
|
namespace AD.VosacoSDK
|
||||||
{
|
{
|
||||||
// ISDKInitCallback.cs
|
// ISDKInitCallback.cs
|
||||||
public class ISDKInitCallback : AndroidJavaProxy
|
public class ISDKInitCallback : AndroidJavaProxy
|
||||||
{
|
{
|
||||||
public Action<bool, string> onInitResult;
|
public Action<bool, string> onInitResult;
|
||||||
|
|
||||||
public ISDKInitCallback() : base("com.rixengine.unity_plugin.ISDKInit") { }
|
public ISDKInitCallback() : base("com.rixengine.unity_plugin.ISDKInit") { }
|
||||||
|
|
||||||
public void initResult(bool success, string message)
|
public void initResult(bool success, string message)
|
||||||
{
|
{
|
||||||
onInitResult?.Invoke(success, message);
|
onInitResult?.Invoke(success, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
Regular → Executable
+80
-80
@@ -1,80 +1,80 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AD.VosacoSDK
|
namespace AD.VosacoSDK
|
||||||
{
|
{
|
||||||
public class VosacoAdSDK
|
public class VosacoAdSDK
|
||||||
{
|
{
|
||||||
private static AndroidJavaClass _adClass;
|
private static AndroidJavaClass _adClass;
|
||||||
|
|
||||||
// 初始化SDK
|
// 初始化SDK
|
||||||
public static void Initialize(string host, string token, string sid, string appId, Action<bool, string> callback)
|
public static void Initialize(string host, string token, string sid, string appId, Action<bool, string> callback)
|
||||||
{
|
{
|
||||||
if (Application.platform != RuntimePlatform.Android)
|
if (Application.platform != RuntimePlatform.Android)
|
||||||
{
|
{
|
||||||
LogD("SDK only works on Android platform");
|
LogD("SDK only works on Android platform");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 创建Java回调对象
|
// 创建Java回调对象
|
||||||
var initCallback = new ISDKInitCallback
|
var initCallback = new ISDKInitCallback
|
||||||
{
|
{
|
||||||
onInitResult = callback
|
onInitResult = callback
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用Java方法
|
// 调用Java方法
|
||||||
GetAdClass().CallStatic("init", host, token, sid, appId, initCallback);
|
GetAdClass().CallStatic("init", host, token, sid, appId, initCallback);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogE($"Initialize failed: {e.Message}");
|
LogE($"Initialize failed: {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其他接口封装
|
// 其他接口封装
|
||||||
public static void SetDebug(bool enable) => GetAdClass().CallStatic("setDebug", enable);
|
public static void SetDebug(bool enable) => GetAdClass().CallStatic("setDebug", enable);
|
||||||
|
|
||||||
public static void SetGDPRConsent(bool consent) => GetAdClass().CallStatic("setSubjectToGDPR", consent);
|
public static void SetGDPRConsent(bool consent) => GetAdClass().CallStatic("setSubjectToGDPR", consent);
|
||||||
|
|
||||||
public static void SetUserConsent(string consent) => GetAdClass().CallStatic("setUserConsent", consent);
|
public static void SetUserConsent(string consent) => GetAdClass().CallStatic("setUserConsent", consent);
|
||||||
|
|
||||||
public static void SetUSPrivacy(string privacy) => GetAdClass().CallStatic("subjectToUSPrivacy", privacy);
|
public static void SetUSPrivacy(string privacy) => GetAdClass().CallStatic("subjectToUSPrivacy", privacy);
|
||||||
|
|
||||||
public static void SetExtraParameters(Dictionary<string, object> parameters)
|
public static void SetExtraParameters(Dictionary<string, object> parameters)
|
||||||
{
|
{
|
||||||
using AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
using AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
||||||
foreach (var kv in parameters)
|
foreach (var kv in parameters)
|
||||||
{
|
{
|
||||||
map.Call<AndroidJavaObject>("put", kv.Key, kv.Value);
|
map.Call<AndroidJavaObject>("put", kv.Key, kv.Value);
|
||||||
}
|
}
|
||||||
GetAdClass().CallStatic("setExtraParameters", map);
|
GetAdClass().CallStatic("setExtraParameters", map);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取网络信息
|
// 获取网络信息
|
||||||
public static string GetNetworkName() => GetAdClass().CallStatic<string>("getNetWorkName");
|
public static string GetNetworkName() => GetAdClass().CallStatic<string>("getNetWorkName");
|
||||||
public static string GetNetworkVersion() => GetAdClass().CallStatic<string>("getNetWorkVersion");
|
public static string GetNetworkVersion() => GetAdClass().CallStatic<string>("getNetWorkVersion");
|
||||||
|
|
||||||
public static void LogD(string msg)
|
public static void LogD(string msg)
|
||||||
{
|
{
|
||||||
GetAdClass().CallStatic("LogD", msg);
|
GetAdClass().CallStatic("LogD", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogE(string msg)
|
public static void LogE(string msg)
|
||||||
{
|
{
|
||||||
GetAdClass().CallStatic("LogE", msg);
|
GetAdClass().CallStatic("LogE", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AndroidJavaClass GetAdClass()
|
private static AndroidJavaClass GetAdClass()
|
||||||
{
|
{
|
||||||
if (_adClass == null)
|
if (_adClass == null)
|
||||||
{
|
{
|
||||||
_adClass = new AndroidJavaClass("com.rixengine.unity_plugin.RiEngineAd");
|
_adClass = new AndroidJavaClass("com.rixengine.unity_plugin.RiEngineAd");
|
||||||
}
|
}
|
||||||
return _adClass;
|
return _adClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+157
-157
@@ -1,157 +1,157 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AD.VosacoSDK
|
namespace AD.VosacoSDK
|
||||||
{
|
{
|
||||||
public class VosacoInterAd
|
public class VosacoInterAd
|
||||||
{
|
{
|
||||||
private AndroidJavaObject _interAd;
|
private AndroidJavaObject _interAd;
|
||||||
private VosacoInterAdListenerProxy _listenerProxy;
|
private VosacoInterAdListenerProxy _listenerProxy;
|
||||||
|
|
||||||
public VosacoInterAd(string unitId)
|
public VosacoInterAd(string unitId)
|
||||||
{
|
{
|
||||||
if (Application.platform != RuntimePlatform.Android)
|
if (Application.platform != RuntimePlatform.Android)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 创建Java插屏广告对象
|
// 创建Java插屏广告对象
|
||||||
_interAd = new AndroidJavaObject("com.rixengine.unity_plugin.InterAd", unitId);
|
_interAd = new AndroidJavaObject("com.rixengine.unity_plugin.InterAd", unitId);
|
||||||
|
|
||||||
// 创建并设置监听器
|
// 创建并设置监听器
|
||||||
_listenerProxy = new VosacoInterAdListenerProxy();
|
_listenerProxy = new VosacoInterAdListenerProxy();
|
||||||
_interAd.Call("SetListener", _listenerProxy);
|
_interAd.Call("SetListener", _listenerProxy);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"InterAd creation failed: {e.Message}");
|
VosacoAdSDK.LogE($"InterAd creation failed: {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载广告
|
// 加载广告
|
||||||
public void LoadAd()
|
public void LoadAd()
|
||||||
{
|
{
|
||||||
if (!IsValid()) return;
|
if (!IsValid()) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_interAd.Call("Load");
|
_interAd.Call("Load");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示广告
|
// 显示广告
|
||||||
public void ShowAd()
|
public void ShowAd()
|
||||||
{
|
{
|
||||||
if (!IsValid()) return;
|
if (!IsValid()) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_interAd.Call("Show");
|
_interAd.Call("Show");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查广告是否就绪
|
// 检查广告是否就绪
|
||||||
public bool IsAdReady()
|
public bool IsAdReady()
|
||||||
{
|
{
|
||||||
if (!IsValid()) return false;
|
if (!IsValid()) return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _interAd.Call<bool>("IsReady");
|
return _interAd.Call<bool>("IsReady");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}" );
|
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取广告价格
|
// 获取广告价格
|
||||||
public double GetAdPrice()
|
public double GetAdPrice()
|
||||||
{
|
{
|
||||||
if (!IsValid()) return 0;
|
if (!IsValid()) return 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _interAd.Call<double>("GetPrice");
|
return _interAd.Call<double>("GetPrice");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 销毁广告对象
|
// 销毁广告对象
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
if (!IsValid()) return;
|
if (!IsValid()) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_interAd.Call("Destroy");
|
_interAd.Call("Destroy");
|
||||||
_interAd?.Dispose();
|
_interAd?.Dispose();
|
||||||
_interAd = null;
|
_interAd = null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册事件监听器
|
// 注册事件监听器
|
||||||
public void AddLoadedListener(Action callback)
|
public void AddLoadedListener(Action callback)
|
||||||
=> _listenerProxy.OnLoaded += callback;
|
=> _listenerProxy.OnLoaded += callback;
|
||||||
|
|
||||||
public void AddLoadFailedListener(Action callback)
|
public void AddLoadFailedListener(Action callback)
|
||||||
=> _listenerProxy.OnLoadFailed += callback;
|
=> _listenerProxy.OnLoadFailed += callback;
|
||||||
|
|
||||||
public void AddClickedListener(Action callback)
|
public void AddClickedListener(Action callback)
|
||||||
=> _listenerProxy.OnClicked += callback;
|
=> _listenerProxy.OnClicked += callback;
|
||||||
|
|
||||||
public void AddShowListener(Action callback)
|
public void AddShowListener(Action callback)
|
||||||
=> _listenerProxy.OnShow += callback;
|
=> _listenerProxy.OnShow += callback;
|
||||||
|
|
||||||
public void AddCloseListener(Action callback)
|
public void AddCloseListener(Action callback)
|
||||||
=> _listenerProxy.OnClose += callback;
|
=> _listenerProxy.OnClose += callback;
|
||||||
|
|
||||||
public void AddVideoStartListener(Action callback)
|
public void AddVideoStartListener(Action callback)
|
||||||
=> _listenerProxy.OnVideoStart += callback;
|
=> _listenerProxy.OnVideoStart += callback;
|
||||||
|
|
||||||
public void AddVideoEndListener(Action callback)
|
public void AddVideoEndListener(Action callback)
|
||||||
=> _listenerProxy.OnVideoEnd += callback;
|
=> _listenerProxy.OnVideoEnd += callback;
|
||||||
|
|
||||||
public void AddVideoErrorListener(Action callback)
|
public void AddVideoErrorListener(Action callback)
|
||||||
=> _listenerProxy.OnVideoError += callback;
|
=> _listenerProxy.OnVideoError += callback;
|
||||||
|
|
||||||
|
|
||||||
private bool IsValid()
|
private bool IsValid()
|
||||||
{
|
{
|
||||||
if (Application.platform != RuntimePlatform.Android)
|
if (Application.platform != RuntimePlatform.Android)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_interAd == null)
|
if (_interAd == null)
|
||||||
{
|
{
|
||||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user