[M] AF ad Rvenenue , max Ad
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
bin
|
bin
|
||||||
bin_BurstDebugInformation_DoNotShip
|
bin_BurstDebugInformation_DoNotShip
|
||||||
sdk-intergration/.vscode
|
sdk-intergration/.vscode
|
||||||
|
sdk-intergration/'
|
||||||
|
|||||||
34
sdk-intergration/Assets/AppsFlyer/AFAdRevenueEvent.cs
Normal file
34
sdk-intergration/Assets/AppsFlyer/AFAdRevenueEvent.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AFAdRevenueEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Pre-defined keys for non-mandatory dictionary
|
||||||
|
*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";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Provided by Facebook Audience Network only, and will be reported to publishers
|
||||||
|
*approved by Facebook Audience Network within the closed beta
|
||||||
|
**/
|
||||||
|
public const string ECPM_PAYLOAD = "ecpm_payload";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
sdk-intergration/Assets/AppsFlyer/AFAdRevenueEvent.cs.meta
Normal file
11
sdk-intergration/Assets/AppsFlyer/AFAdRevenueEvent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b73b301ad8b6f4b45809980800a9358a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
178
sdk-intergration/Assets/AppsFlyer/AppsFlyerAdRevenue.cs
Normal file
178
sdk-intergration/Assets/AppsFlyer/AppsFlyerAdRevenue.cs
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AppsFlyerSDK
|
||||||
|
{
|
||||||
|
public class AppsFlyerAdRevenue : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public static readonly string kAppsFlyerAdRevenueVersion = "6.14.3";
|
||||||
|
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
private static AndroidJavaClass appsFlyerAndroid = new AndroidJavaClass("com.appsflyer.unity.afunityadrevenuegenericplugin.AdRevenueUnityWrapper");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static void start()
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
|
||||||
|
_start();
|
||||||
|
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
|
||||||
|
using(AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
|
||||||
|
|
||||||
|
using(AndroidJavaObject cls_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
|
||||||
|
|
||||||
|
AndroidJavaObject cls_Application = cls_Activity.Call<AndroidJavaObject>("getApplication");
|
||||||
|
|
||||||
|
appsFlyerAndroid.CallStatic("start", cls_Application);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setIsDebug(bool isDebug)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
_setIsDebugAdrevenue(isDebug);
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logAdRevenue(string monetizationNetwork,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkType mediationNetwork,
|
||||||
|
double eventRevenue,
|
||||||
|
string revenueCurrency,
|
||||||
|
Dictionary<string, string> additionalParameters)
|
||||||
|
{
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
|
||||||
|
_logAdRevenue(monetizationNetwork, mediationNetwork, eventRevenue, revenueCurrency, AFMiniJSON.Json.Serialize(additionalParameters));
|
||||||
|
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
|
||||||
|
int mediationNetworkAndroid = setMediationNetworkTypeAndroid(mediationNetwork);
|
||||||
|
if (mediationNetworkAndroid == -1)
|
||||||
|
{
|
||||||
|
Debug.Log("Please choose a valid mediationNetwork");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
appsFlyerAndroid.CallStatic("logAdRevenue",
|
||||||
|
monetizationNetwork,
|
||||||
|
mediationNetworkAndroid,
|
||||||
|
revenueCurrency,
|
||||||
|
eventRevenue,
|
||||||
|
convertDictionaryToJavaMap(additionalParameters));
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _start();
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _setIsDebugAdrevenue(bool isDebug);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void _logAdRevenue(string monetizationNetwork,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkType mediationNetwork,
|
||||||
|
double eventRevenue,
|
||||||
|
string revenueCurrency,
|
||||||
|
string additionalParameters);
|
||||||
|
|
||||||
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private static int setMediationNetworkTypeAndroid(AppsFlyerAdRevenueMediationNetworkType mediationNetwork)
|
||||||
|
{
|
||||||
|
switch (mediationNetwork)
|
||||||
|
{
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeIronSource:
|
||||||
|
return 0;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeApplovinMax:
|
||||||
|
return 1;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob:
|
||||||
|
return 2;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeFyber:
|
||||||
|
return 3;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeAppodeal:
|
||||||
|
return 4;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeAdmost:
|
||||||
|
return 5;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeTopon:
|
||||||
|
return 6;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeTradplus:
|
||||||
|
return 7;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeYandex:
|
||||||
|
return 8;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeChartBoost:
|
||||||
|
return 9;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeUnity:
|
||||||
|
return 10;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeCustomMediation:
|
||||||
|
return 11;
|
||||||
|
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypedirectMonetization:
|
||||||
|
return 12;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private static AndroidJavaObject convertDictionaryToJavaMap(Dictionary<string, string> dictionary)
|
||||||
|
{
|
||||||
|
AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
||||||
|
IntPtr putMethod = AndroidJNIHelper.GetMethodID(map.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||||
|
jvalue[] val;
|
||||||
|
if (dictionary != null)
|
||||||
|
{
|
||||||
|
foreach (var entry in dictionary)
|
||||||
|
{
|
||||||
|
val = AndroidJNIHelper.CreateJNIArgArray(new object[] { entry.Key, entry.Value });
|
||||||
|
AndroidJNI.CallObjectMethod(map.GetRawObject(), putMethod, val);
|
||||||
|
AndroidJNI.DeleteLocalRef(val[0].l);
|
||||||
|
AndroidJNI.DeleteLocalRef(val[1].l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum AppsFlyerAdRevenueMediationNetworkType
|
||||||
|
{
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob = 1,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeIronSource = 2,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeApplovinMax = 3,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeFyber = 4,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeAppodeal = 5,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeAdmost = 6,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeTopon = 7,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeTradplus = 8,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeYandex = 9,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeChartBoost = 10,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeUnity = 11,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypeCustomMediation = 12,
|
||||||
|
AppsFlyerAdRevenueMediationNetworkTypedirectMonetization = 13
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
sdk-intergration/Assets/AppsFlyer/AppsFlyerAdRevenue.cs.meta
Normal file
11
sdk-intergration/Assets/AppsFlyer/AppsFlyerAdRevenue.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 644005ac4602e4b78ad3a8d4d29e329d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<dependencies>
|
||||||
|
<androidPackages>
|
||||||
|
<androidPackage spec="com.appsflyer:adrevenue:6.9.1"></androidPackage>
|
||||||
|
<androidPackage spec="com.appsflyer:unity-adrevenue-generic-wrapper:6.9.1"></androidPackage>
|
||||||
|
</androidPackages>
|
||||||
|
|
||||||
|
<iosPods>
|
||||||
|
<iosPod name="AppsFlyer-AdRevenue" version="6.14.3" minTargetSdk="12.0">
|
||||||
|
</iosPod>
|
||||||
|
</iosPods>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6110ce30bf7674268814dc9e0395f8b0
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyerAdRevenueWrapper.h
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 01/12/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#if __has_include(<AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>)
|
||||||
|
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface AppsFlyerAdRevenueWrapper : NSObject
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7fa891a95d71c459daa1e92ee7a653ab
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// AppsFlyerAdRevenueWrapper.mm
|
||||||
|
// Unity-iPhone
|
||||||
|
//
|
||||||
|
// Created by Jonathan Wesfield on 25/11/2019.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AppsFlyerAdRevenueWrapper.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation AppsFlyerAdRevenueWrapper
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
NSString* stringFromChar(const char *str) {
|
||||||
|
return str ? [NSString stringWithUTF8String:str] : nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const void _start(int length, int* adRevenueTypes){
|
||||||
|
[AppsFlyerAdRevenue start];
|
||||||
|
}
|
||||||
|
const void _setIsDebugAdrevenue(bool isDebug){
|
||||||
|
[[AppsFlyerAdRevenue shared] setIsDebug:isDebug];
|
||||||
|
}
|
||||||
|
|
||||||
|
const void _logAdRevenue(const char* monetizationNetwork,
|
||||||
|
int mediationNetwork,
|
||||||
|
double eventRevenue,
|
||||||
|
const char* revenueCurrency,
|
||||||
|
const char* additionalParameters){
|
||||||
|
[[AppsFlyerAdRevenue shared] logAdRevenueWithMonetizationNetwork:stringFromChar(monetizationNetwork)
|
||||||
|
mediationNetwork:(AppsFlyerAdRevenueMediationNetworkType) mediationNetwork
|
||||||
|
eventRevenue:[NSNumber numberWithDouble:eventRevenue]
|
||||||
|
revenueCurrency:stringFromChar(revenueCurrency)
|
||||||
|
additionalParameters:dictionaryFromJson(additionalParameters)];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 84d99cf0f930e4c80b4bc1858e042b70
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
tvOS: tvOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
import Foundation
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a631431c30cca4ac2bb4b40fc67e4005
|
||||||
|
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:
|
||||||
@@ -46,7 +46,8 @@ public class SDKTest : MonoBehaviour
|
|||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
TYSdkFacade.Instance.Init();
|
TYSdkFacade.Instance.Init();
|
||||||
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) => {
|
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) =>
|
||||||
|
{
|
||||||
Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}");
|
Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}");
|
||||||
};
|
};
|
||||||
MaxSdk.InitializeSdk();
|
MaxSdk.InitializeSdk();
|
||||||
@@ -54,12 +55,27 @@ public class SDKTest : MonoBehaviour
|
|||||||
|
|
||||||
AppsFlyer.setIsDebug(true);
|
AppsFlyer.setIsDebug(true);
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C","6505145935");
|
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", "6505145935");
|
||||||
#elif UNITY_ANDROID
|
#elif UNITY_ANDROID
|
||||||
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", null);
|
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", null);
|
||||||
#endif
|
#endif
|
||||||
AppsFlyer.startSDK();
|
AppsFlyer.startSDK();
|
||||||
//AppsFlyerAdRevenue.start();
|
AppsFlyerAdRevenue.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
int retryAttempt;
|
||||||
|
|
||||||
|
public void InitializeRewardedAds()
|
||||||
|
{
|
||||||
|
// Attach callback
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdLoadFailedEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
|
||||||
|
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnLogin(EAccoutType accoutType)
|
private async void OnLogin(EAccoutType accoutType)
|
||||||
@@ -68,7 +84,7 @@ public class SDKTest : MonoBehaviour
|
|||||||
Debug.LogError($"[AggSdk::OnLogin] accoutType : {accoutType}");
|
Debug.LogError($"[AggSdk::OnLogin] accoutType : {accoutType}");
|
||||||
var info = await TYSdkFacade.Instance.Login(accoutType);
|
var info = await TYSdkFacade.Instance.Login(accoutType);
|
||||||
_messageTxt.text = $"Login: {info.isSuccess}";
|
_messageTxt.text = $"Login: {info.isSuccess}";
|
||||||
if(info.isSuccess)
|
if (info.isSuccess)
|
||||||
{
|
{
|
||||||
_messageTxt.text += $"\n{info.msg}";
|
_messageTxt.text += $"\n{info.msg}";
|
||||||
_messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}";
|
_messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}";
|
||||||
@@ -102,15 +118,76 @@ public class SDKTest : MonoBehaviour
|
|||||||
public void OnGaBtn()
|
public void OnGaBtn()
|
||||||
{
|
{
|
||||||
Debug.LogError("Ga ask");
|
Debug.LogError("Ga ask");
|
||||||
using ( var e = GAEvent.TackEvent("idcheckdone") )
|
using (var e = GAEvent.TackEvent("idcheckdone"))
|
||||||
{
|
{
|
||||||
e.AddContent("test ga", true);
|
e.AddContent("test ga", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string AD_ID = "427b872c314ad1f3";
|
||||||
|
|
||||||
public void OnAppMaxBtn()
|
public void OnAppMaxBtn()
|
||||||
{
|
{
|
||||||
//TYSdkFacade.Instance.PlayAd();
|
if (MaxSdk.IsRewardedAdReady(AD_ID))
|
||||||
|
{
|
||||||
|
MaxSdk.ShowRewardedAd(AD_ID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_messageTxt.text = "AD Not Ready, Load now";
|
||||||
|
LoadAd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadAd()
|
||||||
|
{
|
||||||
|
MaxSdk.LoadRewardedAd("427b872c314ad1f3");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
|
{
|
||||||
|
_messageTxt.text = $"Rewarded ad loaded. ID: {adInfo.AdUnitIdentifier}";
|
||||||
|
retryAttempt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
|
{
|
||||||
|
// Rewarded ad failed to load
|
||||||
|
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds).
|
||||||
|
|
||||||
|
retryAttempt++;
|
||||||
|
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
|
||||||
|
_messageTxt.text = $"Rewarded ad failed to load. ID: {adUnitId}. Reason: {errorInfo.Message}. Attempt: {retryAttempt}. Delay: {retryDelay}s.";
|
||||||
|
|
||||||
|
Invoke("LoadAd", (float)retryDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { }
|
||||||
|
|
||||||
|
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
|
||||||
|
{
|
||||||
|
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
|
||||||
|
_messageTxt.text = $"Rewarded ad failed to display. ID: {adUnitId}. Reason: {errorInfo.Message}";
|
||||||
|
LoadAd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { }
|
||||||
|
|
||||||
|
private void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
|
{
|
||||||
|
// Rewarded ad is hidden. Pre-load the next ad
|
||||||
|
_messageTxt.text = $"Rewarded ad hidden. ID: {adUnitId}.";
|
||||||
|
LoadAd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward, MaxSdkBase.AdInfo adInfo)
|
||||||
|
{
|
||||||
|
_messageTxt.text = $"Rewarded ad received reward. ID: {adUnitId}. Type: {reward}. Amount: {reward.Amount}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
|
{
|
||||||
|
_messageTxt.text = $"Rewarded ad revenue paid. ID: {adUnitId}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ extern "C" {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"TYSdkInterface GetSKUList Faild");
|
NSLog(@"TYSdkInterface GetSKUList Faild");
|
||||||
NSLog(@"SKUList %@", resp.errCode);
|
NSLog(@"SKUList %ld %@", resp.errCode, resp.errStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *result = DicTojsonString(resultDict);
|
NSString *result = DicTojsonString(resultDict);
|
||||||
|
|||||||
Reference in New Issue
Block a user